
bin/kernel:     file format elf32-i386


Disassembly of section .text:

00100000 <kern_init>:
int kern_init(void) __attribute__((noreturn));

static void grade_backtrace(void) __attribute__((noinline));

int
kern_init(void) {
  100000:	55                   	push   %ebp
  100001:	89 e5                	mov    %esp,%ebp
  100003:	83 ec 28             	sub    $0x28,%esp
	extern char edata[], end[];
	memset(edata, 0, end - edata);
  100006:	ba ac 9b 10 00       	mov    $0x109bac,%edx
  10000b:	b8 50 95 10 00       	mov    $0x109550,%eax
  100010:	89 d1                	mov    %edx,%ecx
  100012:	29 c1                	sub    %eax,%ecx
  100014:	89 c8                	mov    %ecx,%eax
  100016:	89 44 24 08          	mov    %eax,0x8(%esp)
  10001a:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  100021:	00 
  100022:	c7 04 24 50 95 10 00 	movl   $0x109550,(%esp)
  100029:	e8 85 1d 00 00       	call   101db3 <memset>

	cons_init();				// init the console
  10002e:	e8 a9 12 00 00       	call   1012dc <cons_init>

	const char *message = "(THU.CST) os is loading ...";
  100033:	c7 45 f4 38 1f 10 00 	movl   $0x101f38,-0xc(%ebp)
	cprintf("%s\n\n", message);
  10003a:	8b 45 f4             	mov    -0xc(%ebp),%eax
  10003d:	89 44 24 04          	mov    %eax,0x4(%esp)
  100041:	c7 04 24 54 1f 10 00 	movl   $0x101f54,(%esp)
  100048:	e8 af 01 00 00       	call   1001fc <cprintf>

	// drop into kernel monitor
	grade_backtrace();
  10004d:	e8 79 00 00 00       	call   1000cb <grade_backtrace>
	while (1) {
		monitor(NULL);
  100052:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  100059:	e8 eb 09 00 00       	call   100a49 <monitor>
	}
  10005e:	eb f2                	jmp    100052 <kern_init+0x52>

00100060 <grade_backtrace2>:
}

void __attribute__((noinline))
grade_backtrace2(int arg0, int arg1, int arg2, int arg3) {
  100060:	55                   	push   %ebp
  100061:	89 e5                	mov    %esp,%ebp
  100063:	83 ec 18             	sub    $0x18,%esp
	mon_backtrace(0, NULL, NULL);
  100066:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  10006d:	00 
  10006e:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  100075:	00 
  100076:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  10007d:	e8 85 0a 00 00       	call   100b07 <mon_backtrace>
}
  100082:	c9                   	leave  
  100083:	c3                   	ret    

00100084 <grade_backtrace1>:

void __attribute__((noinline))
grade_backtrace1(int arg0, int arg1) {
  100084:	55                   	push   %ebp
  100085:	89 e5                	mov    %esp,%ebp
  100087:	53                   	push   %ebx
  100088:	83 ec 14             	sub    $0x14,%esp
	grade_backtrace2(arg0, (int)&arg0, arg1, (int)&arg1);
  10008b:	8d 5d 0c             	lea    0xc(%ebp),%ebx
  10008e:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  100091:	8d 55 08             	lea    0x8(%ebp),%edx
  100094:	8b 45 08             	mov    0x8(%ebp),%eax
  100097:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  10009b:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  10009f:	89 54 24 04          	mov    %edx,0x4(%esp)
  1000a3:	89 04 24             	mov    %eax,(%esp)
  1000a6:	e8 b5 ff ff ff       	call   100060 <grade_backtrace2>
}
  1000ab:	83 c4 14             	add    $0x14,%esp
  1000ae:	5b                   	pop    %ebx
  1000af:	5d                   	pop    %ebp
  1000b0:	c3                   	ret    

001000b1 <grade_backtrace0>:

void __attribute__((noinline))
grade_backtrace0(int arg0, int arg1, int arg2) {
  1000b1:	55                   	push   %ebp
  1000b2:	89 e5                	mov    %esp,%ebp
  1000b4:	83 ec 18             	sub    $0x18,%esp
	grade_backtrace1(arg0, arg2);
  1000b7:	8b 45 10             	mov    0x10(%ebp),%eax
  1000ba:	89 44 24 04          	mov    %eax,0x4(%esp)
  1000be:	8b 45 08             	mov    0x8(%ebp),%eax
  1000c1:	89 04 24             	mov    %eax,(%esp)
  1000c4:	e8 bb ff ff ff       	call   100084 <grade_backtrace1>
}
  1000c9:	c9                   	leave  
  1000ca:	c3                   	ret    

001000cb <grade_backtrace>:

void
grade_backtrace(void) {
  1000cb:	55                   	push   %ebp
  1000cc:	89 e5                	mov    %esp,%ebp
  1000ce:	83 ec 18             	sub    $0x18,%esp
#ifdef DEBUG_GRADE
	grade_backtrace0(0, (int)kern_init, 0xffff0000);
  1000d1:	b8 00 00 10 00       	mov    $0x100000,%eax
  1000d6:	c7 44 24 08 00 00 ff 	movl   $0xffff0000,0x8(%esp)
  1000dd:	ff 
  1000de:	89 44 24 04          	mov    %eax,0x4(%esp)
  1000e2:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  1000e9:	e8 c3 ff ff ff       	call   1000b1 <grade_backtrace0>
#endif
}
  1000ee:	c9                   	leave  
  1000ef:	c3                   	ret    

001000f0 <readline>:
 * The readline() function returns the text of the line read. If some errors
 * are happened, NULL is returned. The return value is a global variable,
 * thus it should be copied before it is used.
 * */
char *
readline(const char *prompt) {
  1000f0:	55                   	push   %ebp
  1000f1:	89 e5                	mov    %esp,%ebp
  1000f3:	83 ec 28             	sub    $0x28,%esp
	if (prompt != NULL) {
  1000f6:	83 7d 08 00          	cmpl   $0x0,0x8(%ebp)
  1000fa:	74 13                	je     10010f <readline+0x1f>
		cprintf("%s", prompt);
  1000fc:	8b 45 08             	mov    0x8(%ebp),%eax
  1000ff:	89 44 24 04          	mov    %eax,0x4(%esp)
  100103:	c7 04 24 59 1f 10 00 	movl   $0x101f59,(%esp)
  10010a:	e8 ed 00 00 00       	call   1001fc <cprintf>
	}
	int i = 0, c;
  10010f:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  100116:	eb 01                	jmp    100119 <readline+0x29>
		else if (c == '\n' || c == '\r') {
			cputchar(c);
			buf[i] = '\0';
			return buf;
		}
	}
  100118:	90                   	nop
	if (prompt != NULL) {
		cprintf("%s", prompt);
	}
	int i = 0, c;
	while (1) {
		c = getchar();
  100119:	e8 6c 01 00 00       	call   10028a <getchar>
  10011e:	89 45 f4             	mov    %eax,-0xc(%ebp)
		if (c < 0) {
  100121:	83 7d f4 00          	cmpl   $0x0,-0xc(%ebp)
  100125:	79 07                	jns    10012e <readline+0x3e>
			return NULL;
  100127:	b8 00 00 00 00       	mov    $0x0,%eax
  10012c:	eb 76                	jmp    1001a4 <readline+0xb4>
		}
		else if (c >= ' ' && i < BUFSIZE - 1) {
  10012e:	83 7d f4 1f          	cmpl   $0x1f,-0xc(%ebp)
  100132:	7e 26                	jle    10015a <readline+0x6a>
  100134:	81 7d f0 fe 03 00 00 	cmpl   $0x3fe,-0x10(%ebp)
  10013b:	7f 1d                	jg     10015a <readline+0x6a>
			cputchar(c);
  10013d:	8b 45 f4             	mov    -0xc(%ebp),%eax
  100140:	89 04 24             	mov    %eax,(%esp)
  100143:	e8 dd 00 00 00       	call   100225 <cputchar>
			buf[i ++] = c;
  100148:	8b 45 f0             	mov    -0x10(%ebp),%eax
  10014b:	8b 55 f4             	mov    -0xc(%ebp),%edx
  10014e:	88 90 60 95 10 00    	mov    %dl,0x109560(%eax)
  100154:	83 45 f0 01          	addl   $0x1,-0x10(%ebp)
	while (1) {
		c = getchar();
		if (c < 0) {
			return NULL;
		}
		else if (c >= ' ' && i < BUFSIZE - 1) {
  100158:	eb 45                	jmp    10019f <readline+0xaf>
			cputchar(c);
			buf[i ++] = c;
		}
		else if (c == '\b' && i > 0) {
  10015a:	83 7d f4 08          	cmpl   $0x8,-0xc(%ebp)
  10015e:	75 17                	jne    100177 <readline+0x87>
  100160:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  100164:	7e 11                	jle    100177 <readline+0x87>
			cputchar(c);
  100166:	8b 45 f4             	mov    -0xc(%ebp),%eax
  100169:	89 04 24             	mov    %eax,(%esp)
  10016c:	e8 b4 00 00 00       	call   100225 <cputchar>
			i --;
  100171:	83 6d f0 01          	subl   $0x1,-0x10(%ebp)
		}
		else if (c >= ' ' && i < BUFSIZE - 1) {
			cputchar(c);
			buf[i ++] = c;
		}
		else if (c == '\b' && i > 0) {
  100175:	eb 28                	jmp    10019f <readline+0xaf>
			cputchar(c);
			i --;
		}
		else if (c == '\n' || c == '\r') {
  100177:	83 7d f4 0a          	cmpl   $0xa,-0xc(%ebp)
  10017b:	74 06                	je     100183 <readline+0x93>
  10017d:	83 7d f4 0d          	cmpl   $0xd,-0xc(%ebp)
  100181:	75 95                	jne    100118 <readline+0x28>
			cputchar(c);
  100183:	8b 45 f4             	mov    -0xc(%ebp),%eax
  100186:	89 04 24             	mov    %eax,(%esp)
  100189:	e8 97 00 00 00       	call   100225 <cputchar>
			buf[i] = '\0';
  10018e:	8b 45 f0             	mov    -0x10(%ebp),%eax
  100191:	c6 80 60 95 10 00 00 	movb   $0x0,0x109560(%eax)
			return buf;
  100198:	b8 60 95 10 00       	mov    $0x109560,%eax
  10019d:	eb 05                	jmp    1001a4 <readline+0xb4>
		}
	}
  10019f:	e9 75 ff ff ff       	jmp    100119 <readline+0x29>
}
  1001a4:	c9                   	leave  
  1001a5:	c3                   	ret    
	...

001001a8 <cputch>:
/* *
 * cputch - writes a single character @c to stdout, and it will
 * increace the value of counter pointed by @cnt.
 * */
static void
cputch(int c, int *cnt) {
  1001a8:	55                   	push   %ebp
  1001a9:	89 e5                	mov    %esp,%ebp
  1001ab:	83 ec 18             	sub    $0x18,%esp
	cons_putc(c);
  1001ae:	8b 45 08             	mov    0x8(%ebp),%eax
  1001b1:	89 04 24             	mov    %eax,(%esp)
  1001b4:	e8 4f 11 00 00       	call   101308 <cons_putc>
	(*cnt) ++;
  1001b9:	8b 45 0c             	mov    0xc(%ebp),%eax
  1001bc:	8b 00                	mov    (%eax),%eax
  1001be:	8d 50 01             	lea    0x1(%eax),%edx
  1001c1:	8b 45 0c             	mov    0xc(%ebp),%eax
  1001c4:	89 10                	mov    %edx,(%eax)
}
  1001c6:	c9                   	leave  
  1001c7:	c3                   	ret    

001001c8 <vcprintf>:
 *
 * Call this function if you are already dealing with a va_list.
 * Or you probably want cprintf() instead.
 * */
int
vcprintf(const char *fmt, va_list ap) {
  1001c8:	55                   	push   %ebp
  1001c9:	89 e5                	mov    %esp,%ebp
  1001cb:	83 ec 28             	sub    $0x28,%esp
	int cnt = 0;
  1001ce:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
	vprintfmt((void*)cputch, &cnt, fmt, ap);
  1001d5:	b8 a8 01 10 00       	mov    $0x1001a8,%eax
  1001da:	8b 55 0c             	mov    0xc(%ebp),%edx
  1001dd:	89 54 24 0c          	mov    %edx,0xc(%esp)
  1001e1:	8b 55 08             	mov    0x8(%ebp),%edx
  1001e4:	89 54 24 08          	mov    %edx,0x8(%esp)
  1001e8:	8d 55 f4             	lea    -0xc(%ebp),%edx
  1001eb:	89 54 24 04          	mov    %edx,0x4(%esp)
  1001ef:	89 04 24             	mov    %eax,(%esp)
  1001f2:	e8 98 13 00 00       	call   10158f <vprintfmt>
	return cnt;
  1001f7:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  1001fa:	c9                   	leave  
  1001fb:	c3                   	ret    

001001fc <cprintf>:
 *
 * The return value is the number of characters which would be
 * written to stdout.
 * */
int
cprintf(const char *fmt, ...) {
  1001fc:	55                   	push   %ebp
  1001fd:	89 e5                	mov    %esp,%ebp
  1001ff:	83 ec 28             	sub    $0x28,%esp
	va_list ap;
	int cnt;
	va_start(ap, fmt);
  100202:	8d 45 08             	lea    0x8(%ebp),%eax
  100205:	83 c0 04             	add    $0x4,%eax
  100208:	89 45 f0             	mov    %eax,-0x10(%ebp)
	cnt = vcprintf(fmt, ap);
  10020b:	8b 45 08             	mov    0x8(%ebp),%eax
  10020e:	8b 55 f0             	mov    -0x10(%ebp),%edx
  100211:	89 54 24 04          	mov    %edx,0x4(%esp)
  100215:	89 04 24             	mov    %eax,(%esp)
  100218:	e8 ab ff ff ff       	call   1001c8 <vcprintf>
  10021d:	89 45 f4             	mov    %eax,-0xc(%ebp)
	va_end(ap);
	return cnt;
  100220:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  100223:	c9                   	leave  
  100224:	c3                   	ret    

00100225 <cputchar>:

/* cputchar - writes a single character to stdout */
void
cputchar(int c) {
  100225:	55                   	push   %ebp
  100226:	89 e5                	mov    %esp,%ebp
  100228:	83 ec 18             	sub    $0x18,%esp
	cons_putc(c);
  10022b:	8b 45 08             	mov    0x8(%ebp),%eax
  10022e:	89 04 24             	mov    %eax,(%esp)
  100231:	e8 d2 10 00 00       	call   101308 <cons_putc>
}
  100236:	c9                   	leave  
  100237:	c3                   	ret    

00100238 <cputs>:
/* *
 * cputs- writes the string pointed by @str to stdout and
 * appends a newline character.
 * */
int
cputs(const char *str) {
  100238:	55                   	push   %ebp
  100239:	89 e5                	mov    %esp,%ebp
  10023b:	83 ec 28             	sub    $0x28,%esp
	int cnt = 0;
  10023e:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
	char c;
	while ((c = *str ++) != '\0') {
  100245:	eb 13                	jmp    10025a <cputs+0x22>
		cputch(c, &cnt);
  100247:	0f be 45 f7          	movsbl -0x9(%ebp),%eax
  10024b:	8d 55 f0             	lea    -0x10(%ebp),%edx
  10024e:	89 54 24 04          	mov    %edx,0x4(%esp)
  100252:	89 04 24             	mov    %eax,(%esp)
  100255:	e8 4e ff ff ff       	call   1001a8 <cputch>
 * */
int
cputs(const char *str) {
	int cnt = 0;
	char c;
	while ((c = *str ++) != '\0') {
  10025a:	8b 45 08             	mov    0x8(%ebp),%eax
  10025d:	0f b6 00             	movzbl (%eax),%eax
  100260:	88 45 f7             	mov    %al,-0x9(%ebp)
  100263:	80 7d f7 00          	cmpb   $0x0,-0x9(%ebp)
  100267:	0f 95 c0             	setne  %al
  10026a:	83 45 08 01          	addl   $0x1,0x8(%ebp)
  10026e:	84 c0                	test   %al,%al
  100270:	75 d5                	jne    100247 <cputs+0xf>
		cputch(c, &cnt);
	}
	cputch('\n', &cnt);
  100272:	8d 45 f0             	lea    -0x10(%ebp),%eax
  100275:	89 44 24 04          	mov    %eax,0x4(%esp)
  100279:	c7 04 24 0a 00 00 00 	movl   $0xa,(%esp)
  100280:	e8 23 ff ff ff       	call   1001a8 <cputch>
	return cnt;
  100285:	8b 45 f0             	mov    -0x10(%ebp),%eax
}
  100288:	c9                   	leave  
  100289:	c3                   	ret    

0010028a <getchar>:

/* getchar - reads a single non-zero character from stdin */
int
getchar(void) {
  10028a:	55                   	push   %ebp
  10028b:	89 e5                	mov    %esp,%ebp
  10028d:	83 ec 18             	sub    $0x18,%esp
	int c;
	while ((c = cons_getc()) == 0)
  100290:	e8 9c 10 00 00       	call   101331 <cons_getc>
  100295:	89 45 f4             	mov    %eax,-0xc(%ebp)
  100298:	83 7d f4 00          	cmpl   $0x0,-0xc(%ebp)
  10029c:	74 f2                	je     100290 <getchar+0x6>
		/* do nothing */;
	return c;
  10029e:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  1002a1:	c9                   	leave  
  1002a2:	c3                   	ret    
	...

001002a4 <stab_binsearch>:
 *      stab_binsearch(stabs, &left, &right, N_SO, 0xf0100184);
 * will exit setting left = 118, right = 554.
 * */
static void stab_binsearch(const struct stab *stabs, int *region_left, int *region_right,
	       int type, uintptr_t addr) 
{
  1002a4:	55                   	push   %ebp
  1002a5:	89 e5                	mov    %esp,%ebp
  1002a7:	83 ec 20             	sub    $0x20,%esp
	int l = *region_left, r = *region_right, any_matches = 0;
  1002aa:	8b 45 0c             	mov    0xc(%ebp),%eax
  1002ad:	8b 00                	mov    (%eax),%eax
  1002af:	89 45 ec             	mov    %eax,-0x14(%ebp)
  1002b2:	8b 45 10             	mov    0x10(%ebp),%eax
  1002b5:	8b 00                	mov    (%eax),%eax
  1002b7:	89 45 f0             	mov    %eax,-0x10(%ebp)
  1002ba:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	while (l <= r) 
  1002c1:	e9 c8 00 00 00       	jmp    10038e <stab_binsearch+0xea>
	{
		int true_m = (l + r) / 2, m = true_m;
  1002c6:	8b 45 f0             	mov    -0x10(%ebp),%eax
  1002c9:	8b 55 ec             	mov    -0x14(%ebp),%edx
  1002cc:	8d 04 02             	lea    (%edx,%eax,1),%eax
  1002cf:	89 c2                	mov    %eax,%edx
  1002d1:	c1 ea 1f             	shr    $0x1f,%edx
  1002d4:	8d 04 02             	lea    (%edx,%eax,1),%eax
  1002d7:	d1 f8                	sar    %eax
  1002d9:	89 45 f8             	mov    %eax,-0x8(%ebp)
  1002dc:	8b 45 f8             	mov    -0x8(%ebp),%eax
  1002df:	89 45 fc             	mov    %eax,-0x4(%ebp)

		// search for earliest stab with right type
		while (m >= l && stabs[m].n_type != type) 
  1002e2:	eb 04                	jmp    1002e8 <stab_binsearch+0x44>
		{
			m --;
  1002e4:	83 6d fc 01          	subl   $0x1,-0x4(%ebp)
	while (l <= r) 
	{
		int true_m = (l + r) / 2, m = true_m;

		// search for earliest stab with right type
		while (m >= l && stabs[m].n_type != type) 
  1002e8:	8b 45 fc             	mov    -0x4(%ebp),%eax
  1002eb:	3b 45 ec             	cmp    -0x14(%ebp),%eax
  1002ee:	7c 1b                	jl     10030b <stab_binsearch+0x67>
  1002f0:	8b 55 fc             	mov    -0x4(%ebp),%edx
  1002f3:	89 d0                	mov    %edx,%eax
  1002f5:	01 c0                	add    %eax,%eax
  1002f7:	01 d0                	add    %edx,%eax
  1002f9:	c1 e0 02             	shl    $0x2,%eax
  1002fc:	03 45 08             	add    0x8(%ebp),%eax
  1002ff:	0f b6 40 04          	movzbl 0x4(%eax),%eax
  100303:	0f b6 c0             	movzbl %al,%eax
  100306:	3b 45 14             	cmp    0x14(%ebp),%eax
  100309:	75 d9                	jne    1002e4 <stab_binsearch+0x40>
		{
			m --;
		}
		if (m < l) 
  10030b:	8b 45 fc             	mov    -0x4(%ebp),%eax
  10030e:	3b 45 ec             	cmp    -0x14(%ebp),%eax
  100311:	7d 0b                	jge    10031e <stab_binsearch+0x7a>
		{	// no match in [l, m]
			l = true_m + 1;
  100313:	8b 45 f8             	mov    -0x8(%ebp),%eax
  100316:	83 c0 01             	add    $0x1,%eax
  100319:	89 45 ec             	mov    %eax,-0x14(%ebp)
			continue;
  10031c:	eb 70                	jmp    10038e <stab_binsearch+0xea>
		}

		// actual binary search
		any_matches = 1;
  10031e:	c7 45 f4 01 00 00 00 	movl   $0x1,-0xc(%ebp)
		if (stabs[m].n_value < addr) 
  100325:	8b 55 fc             	mov    -0x4(%ebp),%edx
  100328:	89 d0                	mov    %edx,%eax
  10032a:	01 c0                	add    %eax,%eax
  10032c:	01 d0                	add    %edx,%eax
  10032e:	c1 e0 02             	shl    $0x2,%eax
  100331:	03 45 08             	add    0x8(%ebp),%eax
  100334:	8b 40 08             	mov    0x8(%eax),%eax
  100337:	3b 45 18             	cmp    0x18(%ebp),%eax
  10033a:	73 13                	jae    10034f <stab_binsearch+0xab>
		{
			*region_left = m;
  10033c:	8b 45 0c             	mov    0xc(%ebp),%eax
  10033f:	8b 55 fc             	mov    -0x4(%ebp),%edx
  100342:	89 10                	mov    %edx,(%eax)
			l = true_m + 1;
  100344:	8b 45 f8             	mov    -0x8(%ebp),%eax
  100347:	83 c0 01             	add    $0x1,%eax
  10034a:	89 45 ec             	mov    %eax,-0x14(%ebp)
  10034d:	eb 3f                	jmp    10038e <stab_binsearch+0xea>
		} 
		else if (stabs[m].n_value > addr) 
  10034f:	8b 55 fc             	mov    -0x4(%ebp),%edx
  100352:	89 d0                	mov    %edx,%eax
  100354:	01 c0                	add    %eax,%eax
  100356:	01 d0                	add    %edx,%eax
  100358:	c1 e0 02             	shl    $0x2,%eax
  10035b:	03 45 08             	add    0x8(%ebp),%eax
  10035e:	8b 40 08             	mov    0x8(%eax),%eax
  100361:	3b 45 18             	cmp    0x18(%ebp),%eax
  100364:	76 16                	jbe    10037c <stab_binsearch+0xd8>
		{
			*region_right = m - 1;
  100366:	8b 45 fc             	mov    -0x4(%ebp),%eax
  100369:	8d 50 ff             	lea    -0x1(%eax),%edx
  10036c:	8b 45 10             	mov    0x10(%ebp),%eax
  10036f:	89 10                	mov    %edx,(%eax)
			r = m - 1;
  100371:	8b 45 fc             	mov    -0x4(%ebp),%eax
  100374:	83 e8 01             	sub    $0x1,%eax
  100377:	89 45 f0             	mov    %eax,-0x10(%ebp)
  10037a:	eb 12                	jmp    10038e <stab_binsearch+0xea>
		} 
		else 
		{
			// exact match for 'addr', but continue loop to find
			// *region_right
			*region_left = m;
  10037c:	8b 45 0c             	mov    0xc(%ebp),%eax
  10037f:	8b 55 fc             	mov    -0x4(%ebp),%edx
  100382:	89 10                	mov    %edx,(%eax)
			l = m;
  100384:	8b 45 fc             	mov    -0x4(%ebp),%eax
  100387:	89 45 ec             	mov    %eax,-0x14(%ebp)
			addr ++;
  10038a:	83 45 18 01          	addl   $0x1,0x18(%ebp)
static void stab_binsearch(const struct stab *stabs, int *region_left, int *region_right,
	       int type, uintptr_t addr) 
{
	int l = *region_left, r = *region_right, any_matches = 0;

	while (l <= r) 
  10038e:	8b 45 ec             	mov    -0x14(%ebp),%eax
  100391:	3b 45 f0             	cmp    -0x10(%ebp),%eax
  100394:	0f 8e 2c ff ff ff    	jle    1002c6 <stab_binsearch+0x22>
			l = m;
			addr ++;
		}
	}

	if (!any_matches) {
  10039a:	83 7d f4 00          	cmpl   $0x0,-0xc(%ebp)
  10039e:	75 0f                	jne    1003af <stab_binsearch+0x10b>
		*region_right = *region_left - 1;
  1003a0:	8b 45 0c             	mov    0xc(%ebp),%eax
  1003a3:	8b 00                	mov    (%eax),%eax
  1003a5:	8d 50 ff             	lea    -0x1(%eax),%edx
  1003a8:	8b 45 10             	mov    0x10(%ebp),%eax
  1003ab:	89 10                	mov    %edx,(%eax)
  1003ad:	eb 3b                	jmp    1003ea <stab_binsearch+0x146>
	}
	else {
		// find rightmost region containing 'addr'
		l = *region_right;
  1003af:	8b 45 10             	mov    0x10(%ebp),%eax
  1003b2:	8b 00                	mov    (%eax),%eax
  1003b4:	89 45 ec             	mov    %eax,-0x14(%ebp)
		for (; l > *region_left && stabs[l].n_type != type; l --)
  1003b7:	eb 04                	jmp    1003bd <stab_binsearch+0x119>
  1003b9:	83 6d ec 01          	subl   $0x1,-0x14(%ebp)
  1003bd:	8b 45 0c             	mov    0xc(%ebp),%eax
  1003c0:	8b 00                	mov    (%eax),%eax
  1003c2:	3b 45 ec             	cmp    -0x14(%ebp),%eax
  1003c5:	7d 1b                	jge    1003e2 <stab_binsearch+0x13e>
  1003c7:	8b 55 ec             	mov    -0x14(%ebp),%edx
  1003ca:	89 d0                	mov    %edx,%eax
  1003cc:	01 c0                	add    %eax,%eax
  1003ce:	01 d0                	add    %edx,%eax
  1003d0:	c1 e0 02             	shl    $0x2,%eax
  1003d3:	03 45 08             	add    0x8(%ebp),%eax
  1003d6:	0f b6 40 04          	movzbl 0x4(%eax),%eax
  1003da:	0f b6 c0             	movzbl %al,%eax
  1003dd:	3b 45 14             	cmp    0x14(%ebp),%eax
  1003e0:	75 d7                	jne    1003b9 <stab_binsearch+0x115>
			/* do nothing */;
		*region_left = l;
  1003e2:	8b 45 0c             	mov    0xc(%ebp),%eax
  1003e5:	8b 55 ec             	mov    -0x14(%ebp),%edx
  1003e8:	89 10                	mov    %edx,(%eax)
	}
}
  1003ea:	c9                   	leave  
  1003eb:	c3                   	ret    

001003ec <debuginfo_eip>:
 * the specified instruction address, @addr.  Returns 0 if information
 * was found, and negative if not.  But even if it returns negative it
 * has stored some information into '*info'.
 * */
int debuginfo_eip(uintptr_t addr, struct eipdebuginfo *info) 
{
  1003ec:	55                   	push   %ebp
  1003ed:	89 e5                	mov    %esp,%ebp
  1003ef:	53                   	push   %ebx
  1003f0:	83 ec 54             	sub    $0x54,%esp
	const struct stab *stabs, *stab_end;
	const char *stabstr, *stabstr_end;

	info->eip_file = "<unknown>";
  1003f3:	8b 45 0c             	mov    0xc(%ebp),%eax
  1003f6:	c7 00 5c 1f 10 00    	movl   $0x101f5c,(%eax)
	info->eip_line = 0;
  1003fc:	8b 45 0c             	mov    0xc(%ebp),%eax
  1003ff:	c7 40 04 00 00 00 00 	movl   $0x0,0x4(%eax)
	info->eip_fn_name = "<unknown>";
  100406:	8b 45 0c             	mov    0xc(%ebp),%eax
  100409:	c7 40 08 5c 1f 10 00 	movl   $0x101f5c,0x8(%eax)
	info->eip_fn_namelen = 9;
  100410:	8b 45 0c             	mov    0xc(%ebp),%eax
  100413:	c7 40 0c 09 00 00 00 	movl   $0x9,0xc(%eax)
	info->eip_fn_addr = addr;
  10041a:	8b 45 0c             	mov    0xc(%ebp),%eax
  10041d:	8b 55 08             	mov    0x8(%ebp),%edx
  100420:	89 50 10             	mov    %edx,0x10(%eax)
	info->eip_fn_narg = 0;
  100423:	8b 45 0c             	mov    0xc(%ebp),%eax
  100426:	c7 40 14 00 00 00 00 	movl   $0x0,0x14(%eax)

	stabs = __STAB_BEGIN__;
  10042d:	c7 45 e8 e0 23 10 00 	movl   $0x1023e0,-0x18(%ebp)
	stab_end = __STAB_END__;
  100434:	c7 45 ec 7c 6c 10 00 	movl   $0x106c7c,-0x14(%ebp)
	stabstr = __STABSTR_BEGIN__;
  10043b:	c7 45 f0 7d 6c 10 00 	movl   $0x106c7d,-0x10(%ebp)
	stabstr_end = __STABSTR_END__;
  100442:	c7 45 f4 4a 80 10 00 	movl   $0x10804a,-0xc(%ebp)

	// String table validity checks
	if (stabstr_end <= stabstr || stabstr_end[-1] != 0) {
  100449:	8b 45 f4             	mov    -0xc(%ebp),%eax
  10044c:	3b 45 f0             	cmp    -0x10(%ebp),%eax
  10044f:	76 0d                	jbe    10045e <debuginfo_eip+0x72>
  100451:	8b 45 f4             	mov    -0xc(%ebp),%eax
  100454:	83 e8 01             	sub    $0x1,%eax
  100457:	0f b6 00             	movzbl (%eax),%eax
  10045a:	84 c0                	test   %al,%al
  10045c:	74 0a                	je     100468 <debuginfo_eip+0x7c>
		return -1;
  10045e:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  100463:	e9 9e 02 00 00       	jmp    100706 <debuginfo_eip+0x31a>
	// 'eip'.  First, we find the basic source file containing 'eip'.
	// Then, we look in that source file for the function.  Then we look
	// for the line number.

	// Search the entire set of stabs for the source file (type N_SO).
	int lfile = 0, rfile = (stab_end - stabs) - 1;
  100468:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  10046f:	8b 55 ec             	mov    -0x14(%ebp),%edx
  100472:	8b 45 e8             	mov    -0x18(%ebp),%eax
  100475:	89 d1                	mov    %edx,%ecx
  100477:	29 c1                	sub    %eax,%ecx
  100479:	89 c8                	mov    %ecx,%eax
  10047b:	c1 f8 02             	sar    $0x2,%eax
  10047e:	69 c0 ab aa aa aa    	imul   $0xaaaaaaab,%eax,%eax
  100484:	83 e8 01             	sub    $0x1,%eax
  100487:	89 45 e0             	mov    %eax,-0x20(%ebp)
	stab_binsearch(stabs, &lfile, &rfile, N_SO, addr);
  10048a:	8b 45 08             	mov    0x8(%ebp),%eax
  10048d:	89 44 24 10          	mov    %eax,0x10(%esp)
  100491:	c7 44 24 0c 64 00 00 	movl   $0x64,0xc(%esp)
  100498:	00 
  100499:	8d 45 e0             	lea    -0x20(%ebp),%eax
  10049c:	89 44 24 08          	mov    %eax,0x8(%esp)
  1004a0:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  1004a3:	89 44 24 04          	mov    %eax,0x4(%esp)
  1004a7:	8b 45 e8             	mov    -0x18(%ebp),%eax
  1004aa:	89 04 24             	mov    %eax,(%esp)
  1004ad:	e8 f2 fd ff ff       	call   1002a4 <stab_binsearch>
	if (lfile == 0)
  1004b2:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  1004b5:	85 c0                	test   %eax,%eax
  1004b7:	75 0a                	jne    1004c3 <debuginfo_eip+0xd7>
		return -1;
  1004b9:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  1004be:	e9 43 02 00 00       	jmp    100706 <debuginfo_eip+0x31a>

	// Search within that file's stabs for the function definition
	// (N_FUN).
	int lfun = lfile, rfun = rfile;
  1004c3:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  1004c6:	89 45 dc             	mov    %eax,-0x24(%ebp)
  1004c9:	8b 45 e0             	mov    -0x20(%ebp),%eax
  1004cc:	89 45 d8             	mov    %eax,-0x28(%ebp)
	int lline, rline;
	stab_binsearch(stabs, &lfun, &rfun, N_FUN, addr);
  1004cf:	8b 45 08             	mov    0x8(%ebp),%eax
  1004d2:	89 44 24 10          	mov    %eax,0x10(%esp)
  1004d6:	c7 44 24 0c 24 00 00 	movl   $0x24,0xc(%esp)
  1004dd:	00 
  1004de:	8d 45 d8             	lea    -0x28(%ebp),%eax
  1004e1:	89 44 24 08          	mov    %eax,0x8(%esp)
  1004e5:	8d 45 dc             	lea    -0x24(%ebp),%eax
  1004e8:	89 44 24 04          	mov    %eax,0x4(%esp)
  1004ec:	8b 45 e8             	mov    -0x18(%ebp),%eax
  1004ef:	89 04 24             	mov    %eax,(%esp)
  1004f2:	e8 ad fd ff ff       	call   1002a4 <stab_binsearch>

	if (lfun <= rfun) {
  1004f7:	8b 55 dc             	mov    -0x24(%ebp),%edx
  1004fa:	8b 45 d8             	mov    -0x28(%ebp),%eax
  1004fd:	39 c2                	cmp    %eax,%edx
  1004ff:	7f 72                	jg     100573 <debuginfo_eip+0x187>
		// stabs[lfun] points to the function name
		// in the string table, but check bounds just in case.
		if (stabs[lfun].n_strx < stabstr_end - stabstr) {
  100501:	8b 45 dc             	mov    -0x24(%ebp),%eax
  100504:	89 c2                	mov    %eax,%edx
  100506:	89 d0                	mov    %edx,%eax
  100508:	01 c0                	add    %eax,%eax
  10050a:	01 d0                	add    %edx,%eax
  10050c:	c1 e0 02             	shl    $0x2,%eax
  10050f:	03 45 e8             	add    -0x18(%ebp),%eax
  100512:	8b 10                	mov    (%eax),%edx
  100514:	8b 4d f4             	mov    -0xc(%ebp),%ecx
  100517:	8b 45 f0             	mov    -0x10(%ebp),%eax
  10051a:	89 cb                	mov    %ecx,%ebx
  10051c:	29 c3                	sub    %eax,%ebx
  10051e:	89 d8                	mov    %ebx,%eax
  100520:	39 c2                	cmp    %eax,%edx
  100522:	73 1e                	jae    100542 <debuginfo_eip+0x156>
			info->eip_fn_name = stabstr + stabs[lfun].n_strx;
  100524:	8b 45 dc             	mov    -0x24(%ebp),%eax
  100527:	89 c2                	mov    %eax,%edx
  100529:	89 d0                	mov    %edx,%eax
  10052b:	01 c0                	add    %eax,%eax
  10052d:	01 d0                	add    %edx,%eax
  10052f:	c1 e0 02             	shl    $0x2,%eax
  100532:	03 45 e8             	add    -0x18(%ebp),%eax
  100535:	8b 00                	mov    (%eax),%eax
  100537:	89 c2                	mov    %eax,%edx
  100539:	03 55 f0             	add    -0x10(%ebp),%edx
  10053c:	8b 45 0c             	mov    0xc(%ebp),%eax
  10053f:	89 50 08             	mov    %edx,0x8(%eax)
		}
		info->eip_fn_addr = stabs[lfun].n_value;
  100542:	8b 45 dc             	mov    -0x24(%ebp),%eax
  100545:	89 c2                	mov    %eax,%edx
  100547:	89 d0                	mov    %edx,%eax
  100549:	01 c0                	add    %eax,%eax
  10054b:	01 d0                	add    %edx,%eax
  10054d:	c1 e0 02             	shl    $0x2,%eax
  100550:	03 45 e8             	add    -0x18(%ebp),%eax
  100553:	8b 50 08             	mov    0x8(%eax),%edx
  100556:	8b 45 0c             	mov    0xc(%ebp),%eax
  100559:	89 50 10             	mov    %edx,0x10(%eax)
		addr -= info->eip_fn_addr;
  10055c:	8b 45 0c             	mov    0xc(%ebp),%eax
  10055f:	8b 40 10             	mov    0x10(%eax),%eax
  100562:	29 45 08             	sub    %eax,0x8(%ebp)
		// Search within the function definition for the line number.
		lline = lfun;
  100565:	8b 45 dc             	mov    -0x24(%ebp),%eax
  100568:	89 45 d4             	mov    %eax,-0x2c(%ebp)
		rline = rfun;
  10056b:	8b 45 d8             	mov    -0x28(%ebp),%eax
  10056e:	89 45 d0             	mov    %eax,-0x30(%ebp)
  100571:	eb 15                	jmp    100588 <debuginfo_eip+0x19c>
	} else {
		// Couldn't find function stab!  Maybe we're in an assembly
		// file.  Search the whole file for the line number.
		info->eip_fn_addr = addr;
  100573:	8b 45 0c             	mov    0xc(%ebp),%eax
  100576:	8b 55 08             	mov    0x8(%ebp),%edx
  100579:	89 50 10             	mov    %edx,0x10(%eax)
		lline = lfile;
  10057c:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  10057f:	89 45 d4             	mov    %eax,-0x2c(%ebp)
		rline = rfile;
  100582:	8b 45 e0             	mov    -0x20(%ebp),%eax
  100585:	89 45 d0             	mov    %eax,-0x30(%ebp)
	}
	info->eip_fn_namelen = strfind(info->eip_fn_name, ':') - info->eip_fn_name;
  100588:	8b 45 0c             	mov    0xc(%ebp),%eax
  10058b:	8b 40 08             	mov    0x8(%eax),%eax
  10058e:	c7 44 24 04 3a 00 00 	movl   $0x3a,0x4(%esp)
  100595:	00 
  100596:	89 04 24             	mov    %eax,(%esp)
  100599:	e8 8d 16 00 00       	call   101c2b <strfind>
  10059e:	89 c2                	mov    %eax,%edx
  1005a0:	8b 45 0c             	mov    0xc(%ebp),%eax
  1005a3:	8b 40 08             	mov    0x8(%eax),%eax
  1005a6:	29 c2                	sub    %eax,%edx
  1005a8:	8b 45 0c             	mov    0xc(%ebp),%eax
  1005ab:	89 50 0c             	mov    %edx,0xc(%eax)

	// Search within [lline, rline] for the line number stab.
	// If found, set info->eip_line to the right line number.
	// If not found, return -1.
	stab_binsearch(stabs, &lline, &rline, N_SLINE, addr);
  1005ae:	8b 45 08             	mov    0x8(%ebp),%eax
  1005b1:	89 44 24 10          	mov    %eax,0x10(%esp)
  1005b5:	c7 44 24 0c 44 00 00 	movl   $0x44,0xc(%esp)
  1005bc:	00 
  1005bd:	8d 45 d0             	lea    -0x30(%ebp),%eax
  1005c0:	89 44 24 08          	mov    %eax,0x8(%esp)
  1005c4:	8d 45 d4             	lea    -0x2c(%ebp),%eax
  1005c7:	89 44 24 04          	mov    %eax,0x4(%esp)
  1005cb:	8b 45 e8             	mov    -0x18(%ebp),%eax
  1005ce:	89 04 24             	mov    %eax,(%esp)
  1005d1:	e8 ce fc ff ff       	call   1002a4 <stab_binsearch>
	if (lline <= rline) {
  1005d6:	8b 55 d4             	mov    -0x2c(%ebp),%edx
  1005d9:	8b 45 d0             	mov    -0x30(%ebp),%eax
  1005dc:	39 c2                	cmp    %eax,%edx
  1005de:	7f 20                	jg     100600 <debuginfo_eip+0x214>
		info->eip_line = stabs[rline].n_desc;
  1005e0:	8b 45 d0             	mov    -0x30(%ebp),%eax
  1005e3:	89 c2                	mov    %eax,%edx
  1005e5:	89 d0                	mov    %edx,%eax
  1005e7:	01 c0                	add    %eax,%eax
  1005e9:	01 d0                	add    %edx,%eax
  1005eb:	c1 e0 02             	shl    $0x2,%eax
  1005ee:	03 45 e8             	add    -0x18(%ebp),%eax
  1005f1:	0f b7 40 06          	movzwl 0x6(%eax),%eax
  1005f5:	0f b7 d0             	movzwl %ax,%edx
  1005f8:	8b 45 0c             	mov    0xc(%ebp),%eax
  1005fb:	89 50 04             	mov    %edx,0x4(%eax)

	// Search backwards from the line number for the relevant filename stab.
	// We can't just use the "lfile" stab because inlined functions
	// can interpolate code from a different file!
	// Such included source files use the N_SOL stab type.
	while (lline >= lfile
  1005fe:	eb 13                	jmp    100613 <debuginfo_eip+0x227>
	// If not found, return -1.
	stab_binsearch(stabs, &lline, &rline, N_SLINE, addr);
	if (lline <= rline) {
		info->eip_line = stabs[rline].n_desc;
	} else {
		return -1;
  100600:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  100605:	e9 fc 00 00 00       	jmp    100706 <debuginfo_eip+0x31a>
	// can interpolate code from a different file!
	// Such included source files use the N_SOL stab type.
	while (lline >= lfile
	       && stabs[lline].n_type != N_SOL
	       && (stabs[lline].n_type != N_SO || !stabs[lline].n_value)) {
		lline --;
  10060a:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  10060d:	83 e8 01             	sub    $0x1,%eax
  100610:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	// Search backwards from the line number for the relevant filename stab.
	// We can't just use the "lfile" stab because inlined functions
	// can interpolate code from a different file!
	// Such included source files use the N_SOL stab type.
	while (lline >= lfile
	       && stabs[lline].n_type != N_SOL
  100613:	8b 55 d4             	mov    -0x2c(%ebp),%edx
  100616:	8b 45 e4             	mov    -0x1c(%ebp),%eax

	// Search backwards from the line number for the relevant filename stab.
	// We can't just use the "lfile" stab because inlined functions
	// can interpolate code from a different file!
	// Such included source files use the N_SOL stab type.
	while (lline >= lfile
  100619:	39 c2                	cmp    %eax,%edx
  10061b:	7c 4a                	jl     100667 <debuginfo_eip+0x27b>
	       && stabs[lline].n_type != N_SOL
  10061d:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  100620:	89 c2                	mov    %eax,%edx
  100622:	89 d0                	mov    %edx,%eax
  100624:	01 c0                	add    %eax,%eax
  100626:	01 d0                	add    %edx,%eax
  100628:	c1 e0 02             	shl    $0x2,%eax
  10062b:	03 45 e8             	add    -0x18(%ebp),%eax
	       && (stabs[lline].n_type != N_SO || !stabs[lline].n_value)) {
  10062e:	0f b6 40 04          	movzbl 0x4(%eax),%eax

	// Search backwards from the line number for the relevant filename stab.
	// We can't just use the "lfile" stab because inlined functions
	// can interpolate code from a different file!
	// Such included source files use the N_SOL stab type.
	while (lline >= lfile
  100632:	3c 84                	cmp    $0x84,%al
  100634:	74 31                	je     100667 <debuginfo_eip+0x27b>
	       && stabs[lline].n_type != N_SOL
	       && (stabs[lline].n_type != N_SO || !stabs[lline].n_value)) {
  100636:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  100639:	89 c2                	mov    %eax,%edx
  10063b:	89 d0                	mov    %edx,%eax
  10063d:	01 c0                	add    %eax,%eax
  10063f:	01 d0                	add    %edx,%eax
  100641:	c1 e0 02             	shl    $0x2,%eax
  100644:	03 45 e8             	add    -0x18(%ebp),%eax
  100647:	0f b6 40 04          	movzbl 0x4(%eax),%eax

	// Search backwards from the line number for the relevant filename stab.
	// We can't just use the "lfile" stab because inlined functions
	// can interpolate code from a different file!
	// Such included source files use the N_SOL stab type.
	while (lline >= lfile
  10064b:	3c 64                	cmp    $0x64,%al
  10064d:	75 bb                	jne    10060a <debuginfo_eip+0x21e>
	       && stabs[lline].n_type != N_SOL
	       && (stabs[lline].n_type != N_SO || !stabs[lline].n_value)) {
  10064f:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  100652:	89 c2                	mov    %eax,%edx
  100654:	89 d0                	mov    %edx,%eax
  100656:	01 c0                	add    %eax,%eax
  100658:	01 d0                	add    %edx,%eax
  10065a:	c1 e0 02             	shl    $0x2,%eax
  10065d:	03 45 e8             	add    -0x18(%ebp),%eax
  100660:	8b 40 08             	mov    0x8(%eax),%eax

	// Search backwards from the line number for the relevant filename stab.
	// We can't just use the "lfile" stab because inlined functions
	// can interpolate code from a different file!
	// Such included source files use the N_SOL stab type.
	while (lline >= lfile
  100663:	85 c0                	test   %eax,%eax
  100665:	74 a3                	je     10060a <debuginfo_eip+0x21e>
	       && stabs[lline].n_type != N_SOL
	       && (stabs[lline].n_type != N_SO || !stabs[lline].n_value)) {
		lline --;
	}
	if (lline >= lfile && stabs[lline].n_strx < stabstr_end - stabstr) {
  100667:	8b 55 d4             	mov    -0x2c(%ebp),%edx
  10066a:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  10066d:	39 c2                	cmp    %eax,%edx
  10066f:	7c 40                	jl     1006b1 <debuginfo_eip+0x2c5>
  100671:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  100674:	89 c2                	mov    %eax,%edx
  100676:	89 d0                	mov    %edx,%eax
  100678:	01 c0                	add    %eax,%eax
  10067a:	01 d0                	add    %edx,%eax
  10067c:	c1 e0 02             	shl    $0x2,%eax
  10067f:	03 45 e8             	add    -0x18(%ebp),%eax
  100682:	8b 10                	mov    (%eax),%edx
  100684:	8b 4d f4             	mov    -0xc(%ebp),%ecx
  100687:	8b 45 f0             	mov    -0x10(%ebp),%eax
  10068a:	89 cb                	mov    %ecx,%ebx
  10068c:	29 c3                	sub    %eax,%ebx
  10068e:	89 d8                	mov    %ebx,%eax
  100690:	39 c2                	cmp    %eax,%edx
  100692:	73 1d                	jae    1006b1 <debuginfo_eip+0x2c5>
		info->eip_file = stabstr + stabs[lline].n_strx;
  100694:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  100697:	89 c2                	mov    %eax,%edx
  100699:	89 d0                	mov    %edx,%eax
  10069b:	01 c0                	add    %eax,%eax
  10069d:	01 d0                	add    %edx,%eax
  10069f:	c1 e0 02             	shl    $0x2,%eax
  1006a2:	03 45 e8             	add    -0x18(%ebp),%eax
  1006a5:	8b 00                	mov    (%eax),%eax
  1006a7:	89 c2                	mov    %eax,%edx
  1006a9:	03 55 f0             	add    -0x10(%ebp),%edx
  1006ac:	8b 45 0c             	mov    0xc(%ebp),%eax
  1006af:	89 10                	mov    %edx,(%eax)
	}

	// Set eip_fn_narg to the number of arguments taken by the function,
	// or 0 if there was no containing function.
	if (lfun < rfun) {
  1006b1:	8b 55 dc             	mov    -0x24(%ebp),%edx
  1006b4:	8b 45 d8             	mov    -0x28(%ebp),%eax
  1006b7:	39 c2                	cmp    %eax,%edx
  1006b9:	7d 46                	jge    100701 <debuginfo_eip+0x315>
		for (lline = lfun + 1;
  1006bb:	8b 45 dc             	mov    -0x24(%ebp),%eax
  1006be:	83 c0 01             	add    $0x1,%eax
  1006c1:	89 45 d4             	mov    %eax,-0x2c(%ebp)
  1006c4:	eb 18                	jmp    1006de <debuginfo_eip+0x2f2>
		     lline < rfun && stabs[lline].n_type == N_PSYM;
		     lline ++) {
			info->eip_fn_narg ++;
  1006c6:	8b 45 0c             	mov    0xc(%ebp),%eax
  1006c9:	8b 40 14             	mov    0x14(%eax),%eax
  1006cc:	8d 50 01             	lea    0x1(%eax),%edx
  1006cf:	8b 45 0c             	mov    0xc(%ebp),%eax
  1006d2:	89 50 14             	mov    %edx,0x14(%eax)
	// Set eip_fn_narg to the number of arguments taken by the function,
	// or 0 if there was no containing function.
	if (lfun < rfun) {
		for (lline = lfun + 1;
		     lline < rfun && stabs[lline].n_type == N_PSYM;
		     lline ++) {
  1006d5:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  1006d8:	83 c0 01             	add    $0x1,%eax
  1006db:	89 45 d4             	mov    %eax,-0x2c(%ebp)

	// Set eip_fn_narg to the number of arguments taken by the function,
	// or 0 if there was no containing function.
	if (lfun < rfun) {
		for (lline = lfun + 1;
		     lline < rfun && stabs[lline].n_type == N_PSYM;
  1006de:	8b 55 d4             	mov    -0x2c(%ebp),%edx
  1006e1:	8b 45 d8             	mov    -0x28(%ebp),%eax
	}

	// Set eip_fn_narg to the number of arguments taken by the function,
	// or 0 if there was no containing function.
	if (lfun < rfun) {
		for (lline = lfun + 1;
  1006e4:	39 c2                	cmp    %eax,%edx
  1006e6:	7d 19                	jge    100701 <debuginfo_eip+0x315>
		     lline < rfun && stabs[lline].n_type == N_PSYM;
  1006e8:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  1006eb:	89 c2                	mov    %eax,%edx
  1006ed:	89 d0                	mov    %edx,%eax
  1006ef:	01 c0                	add    %eax,%eax
  1006f1:	01 d0                	add    %edx,%eax
  1006f3:	c1 e0 02             	shl    $0x2,%eax
  1006f6:	03 45 e8             	add    -0x18(%ebp),%eax
  1006f9:	0f b6 40 04          	movzbl 0x4(%eax),%eax
	}

	// Set eip_fn_narg to the number of arguments taken by the function,
	// or 0 if there was no containing function.
	if (lfun < rfun) {
		for (lline = lfun + 1;
  1006fd:	3c a0                	cmp    $0xa0,%al
  1006ff:	74 c5                	je     1006c6 <debuginfo_eip+0x2da>
		     lline < rfun && stabs[lline].n_type == N_PSYM;
		     lline ++) {
			info->eip_fn_narg ++;
		}
	}
	return 0;
  100701:	b8 00 00 00 00       	mov    $0x0,%eax
}
  100706:	83 c4 54             	add    $0x54,%esp
  100709:	5b                   	pop    %ebx
  10070a:	5d                   	pop    %ebp
  10070b:	c3                   	ret    

0010070c <print_kerninfo>:
 * print_kerninfo - print the information about kernel, including the location
 * of kernel entry, the start addresses of data and text segements, the start
 * address of free memory and how many memory that kernel has used.
 * */
void print_kerninfo(void) 
{
  10070c:	55                   	push   %ebp
  10070d:	89 e5                	mov    %esp,%ebp
  10070f:	83 ec 18             	sub    $0x18,%esp
	extern char etext[], edata[], end[], kern_init[];
	cprintf("Special kernel symbols:\n");
  100712:	c7 04 24 66 1f 10 00 	movl   $0x101f66,(%esp)
  100719:	e8 de fa ff ff       	call   1001fc <cprintf>
	cprintf("  entry  0x%08x (phys)\n", kern_init);
  10071e:	c7 44 24 04 00 00 10 	movl   $0x100000,0x4(%esp)
  100725:	00 
  100726:	c7 04 24 7f 1f 10 00 	movl   $0x101f7f,(%esp)
  10072d:	e8 ca fa ff ff       	call   1001fc <cprintf>
	cprintf("  etext  0x%08x (phys)\n", etext);
  100732:	c7 44 24 04 37 1f 10 	movl   $0x101f37,0x4(%esp)
  100739:	00 
  10073a:	c7 04 24 97 1f 10 00 	movl   $0x101f97,(%esp)
  100741:	e8 b6 fa ff ff       	call   1001fc <cprintf>
	cprintf("  edata  0x%08x (phys)\n", edata);
  100746:	c7 44 24 04 50 95 10 	movl   $0x109550,0x4(%esp)
  10074d:	00 
  10074e:	c7 04 24 af 1f 10 00 	movl   $0x101faf,(%esp)
  100755:	e8 a2 fa ff ff       	call   1001fc <cprintf>
	cprintf("  end    0x%08x (phys)\n", end);
  10075a:	c7 44 24 04 ac 9b 10 	movl   $0x109bac,0x4(%esp)
  100761:	00 
  100762:	c7 04 24 c7 1f 10 00 	movl   $0x101fc7,(%esp)
  100769:	e8 8e fa ff ff       	call   1001fc <cprintf>
	cprintf("Kernel executable memory footprint: %dKB\n", (end - kern_init + 1023)/1024);
  10076e:	b8 ac 9b 10 00       	mov    $0x109bac,%eax
  100773:	8d 90 ff 03 00 00    	lea    0x3ff(%eax),%edx
  100779:	b8 00 00 10 00       	mov    $0x100000,%eax
  10077e:	89 d1                	mov    %edx,%ecx
  100780:	29 c1                	sub    %eax,%ecx
  100782:	89 c8                	mov    %ecx,%eax
  100784:	8d 90 ff 03 00 00    	lea    0x3ff(%eax),%edx
  10078a:	85 c0                	test   %eax,%eax
  10078c:	0f 48 c2             	cmovs  %edx,%eax
  10078f:	c1 f8 0a             	sar    $0xa,%eax
  100792:	89 44 24 04          	mov    %eax,0x4(%esp)
  100796:	c7 04 24 e0 1f 10 00 	movl   $0x101fe0,(%esp)
  10079d:	e8 5a fa ff ff       	call   1001fc <cprintf>
}
  1007a2:	c9                   	leave  
  1007a3:	c3                   	ret    

001007a4 <print_debuginfo>:
/* *
 * print_debuginfo - read and print the stat information for the address @eip,
 * and info.eip_fn_addr should be the first address of the related function.
 * */
void print_debuginfo(uintptr_t eip) 
{
  1007a4:	55                   	push   %ebp
  1007a5:	89 e5                	mov    %esp,%ebp
  1007a7:	81 ec 48 01 00 00    	sub    $0x148,%esp
	struct eipdebuginfo info;
	if (debuginfo_eip(eip, &info) != 0) {
  1007ad:	8d 45 dc             	lea    -0x24(%ebp),%eax
  1007b0:	89 44 24 04          	mov    %eax,0x4(%esp)
  1007b4:	8b 45 08             	mov    0x8(%ebp),%eax
  1007b7:	89 04 24             	mov    %eax,(%esp)
  1007ba:	e8 2d fc ff ff       	call   1003ec <debuginfo_eip>
  1007bf:	85 c0                	test   %eax,%eax
  1007c1:	74 15                	je     1007d8 <print_debuginfo+0x34>
		cprintf("    <unknow>: -- 0x%08x --\n", eip);
  1007c3:	8b 45 08             	mov    0x8(%ebp),%eax
  1007c6:	89 44 24 04          	mov    %eax,0x4(%esp)
  1007ca:	c7 04 24 0a 20 10 00 	movl   $0x10200a,(%esp)
  1007d1:	e8 26 fa ff ff       	call   1001fc <cprintf>
  1007d6:	eb 68                	jmp    100840 <print_debuginfo+0x9c>
	}
	else {
		char fnname[256];
		int j;
		for (j = 0; j < info.eip_fn_namelen; j ++) {
  1007d8:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  1007df:	eb 1a                	jmp    1007fb <print_debuginfo+0x57>
			fnname[j] = info.eip_fn_name[j];
  1007e1:	8b 45 f4             	mov    -0xc(%ebp),%eax
  1007e4:	8b 4d e4             	mov    -0x1c(%ebp),%ecx
  1007e7:	8b 55 f4             	mov    -0xc(%ebp),%edx
  1007ea:	8d 14 11             	lea    (%ecx,%edx,1),%edx
  1007ed:	0f b6 12             	movzbl (%edx),%edx
  1007f0:	88 94 05 dc fe ff ff 	mov    %dl,-0x124(%ebp,%eax,1)
		cprintf("    <unknow>: -- 0x%08x --\n", eip);
	}
	else {
		char fnname[256];
		int j;
		for (j = 0; j < info.eip_fn_namelen; j ++) {
  1007f7:	83 45 f4 01          	addl   $0x1,-0xc(%ebp)
  1007fb:	8b 45 e8             	mov    -0x18(%ebp),%eax
  1007fe:	3b 45 f4             	cmp    -0xc(%ebp),%eax
  100801:	7f de                	jg     1007e1 <print_debuginfo+0x3d>
			fnname[j] = info.eip_fn_name[j];
		}
		fnname[j] = '\0';
  100803:	8b 45 f4             	mov    -0xc(%ebp),%eax
  100806:	c6 84 05 dc fe ff ff 	movb   $0x0,-0x124(%ebp,%eax,1)
  10080d:	00 
		cprintf("    %s:%d: %s+%d\n", info.eip_file, info.eip_line,
  10080e:	8b 45 ec             	mov    -0x14(%ebp),%eax
  100811:	8b 55 08             	mov    0x8(%ebp),%edx
  100814:	89 d1                	mov    %edx,%ecx
  100816:	29 c1                	sub    %eax,%ecx
  100818:	8b 55 e0             	mov    -0x20(%ebp),%edx
  10081b:	8b 45 dc             	mov    -0x24(%ebp),%eax
  10081e:	89 4c 24 10          	mov    %ecx,0x10(%esp)
  100822:	8d 8d dc fe ff ff    	lea    -0x124(%ebp),%ecx
  100828:	89 4c 24 0c          	mov    %ecx,0xc(%esp)
  10082c:	89 54 24 08          	mov    %edx,0x8(%esp)
  100830:	89 44 24 04          	mov    %eax,0x4(%esp)
  100834:	c7 04 24 26 20 10 00 	movl   $0x102026,(%esp)
  10083b:	e8 bc f9 ff ff       	call   1001fc <cprintf>
				fnname, eip - info.eip_fn_addr);
	}
}
  100840:	c9                   	leave  
  100841:	c3                   	ret    

00100842 <read_eip>:

static uint32_t read_eip(void) __attribute__((noinline));

static uint32_t read_eip(void) 
{
  100842:	55                   	push   %ebp
  100843:	89 e5                	mov    %esp,%ebp
  100845:	83 ec 10             	sub    $0x10,%esp
	uint32_t eip;
	asm volatile("movl 4(%%ebp), %0" : "=r" (eip));
  100848:	8b 45 04             	mov    0x4(%ebp),%eax
  10084b:	89 45 fc             	mov    %eax,-0x4(%ebp)
	return eip;
  10084e:	8b 45 fc             	mov    -0x4(%ebp),%eax
}
  100851:	c9                   	leave  
  100852:	c3                   	ret    

00100853 <print_stackframe>:
 *
 * Note that, the length of ebp-chain is limited. In boot/bootasm.S, before jumping
 * to the kernel entry, the value of ebp has been set to zero, that's the boundary.
 * */
void print_stackframe(void) 
{
  100853:	55                   	push   %ebp
  100854:	89 e5                	mov    %esp,%ebp
  100856:	57                   	push   %edi
  100857:	56                   	push   %esi
  100858:	53                   	push   %ebx
  100859:	83 ec 3c             	sub    $0x3c,%esp
	/* LAB1 YOUR CODE */
	uint32_t eip = read_eip();
  10085c:	e8 e1 ff ff ff       	call   100842 <read_eip>
  100861:	89 45 dc             	mov    %eax,-0x24(%ebp)
	asm volatile ("outw %0, %1" :: "a" (data), "d" (port));
}

static inline uint32_t read_ebp(void) {
	uint32_t ebp;
	asm volatile ("movl %%ebp, %0" : "=r" (ebp));
  100864:	89 e8                	mov    %ebp,%eax
  100866:	89 45 e4             	mov    %eax,-0x1c(%ebp)
	return ebp;
  100869:	8b 45 e4             	mov    -0x1c(%ebp),%eax
	uint32_t ebp = read_ebp();
  10086c:	89 45 e0             	mov    %eax,-0x20(%ebp)
	while(ebp != 0)
  10086f:	eb 6a                	jmp    1008db <print_stackframe+0x88>
	{
		cprintf("ebp:0x%08x eip:0x%08x args:0x%08x 0x%08x 0x%08x 0x%08x\n",*(uint32_t *)ebp,(uint32_t *)eip,*((uint32_t *)ebp+2),*((uint32_t *)ebp+3),*((uint32_t *)ebp+4),*((uint32_t *)ebp+5));
  100871:	8b 45 e0             	mov    -0x20(%ebp),%eax
  100874:	83 c0 14             	add    $0x14,%eax
  100877:	8b 38                	mov    (%eax),%edi
  100879:	8b 45 e0             	mov    -0x20(%ebp),%eax
  10087c:	83 c0 10             	add    $0x10,%eax
  10087f:	8b 30                	mov    (%eax),%esi
  100881:	8b 45 e0             	mov    -0x20(%ebp),%eax
  100884:	83 c0 0c             	add    $0xc,%eax
  100887:	8b 18                	mov    (%eax),%ebx
  100889:	8b 45 e0             	mov    -0x20(%ebp),%eax
  10088c:	83 c0 08             	add    $0x8,%eax
  10088f:	8b 08                	mov    (%eax),%ecx
  100891:	8b 55 dc             	mov    -0x24(%ebp),%edx
  100894:	8b 45 e0             	mov    -0x20(%ebp),%eax
  100897:	8b 00                	mov    (%eax),%eax
  100899:	89 7c 24 18          	mov    %edi,0x18(%esp)
  10089d:	89 74 24 14          	mov    %esi,0x14(%esp)
  1008a1:	89 5c 24 10          	mov    %ebx,0x10(%esp)
  1008a5:	89 4c 24 0c          	mov    %ecx,0xc(%esp)
  1008a9:	89 54 24 08          	mov    %edx,0x8(%esp)
  1008ad:	89 44 24 04          	mov    %eax,0x4(%esp)
  1008b1:	c7 04 24 38 20 10 00 	movl   $0x102038,(%esp)
  1008b8:	e8 3f f9 ff ff       	call   1001fc <cprintf>
		print_debuginfo(eip);
  1008bd:	8b 45 dc             	mov    -0x24(%ebp),%eax
  1008c0:	89 04 24             	mov    %eax,(%esp)
  1008c3:	e8 dc fe ff ff       	call   1007a4 <print_debuginfo>
		eip = *((uint32_t *)ebp + 1);
  1008c8:	8b 45 e0             	mov    -0x20(%ebp),%eax
  1008cb:	83 c0 04             	add    $0x4,%eax
  1008ce:	8b 00                	mov    (%eax),%eax
  1008d0:	89 45 dc             	mov    %eax,-0x24(%ebp)
		ebp = *(uint32_t *)(ebp);
  1008d3:	8b 45 e0             	mov    -0x20(%ebp),%eax
  1008d6:	8b 00                	mov    (%eax),%eax
  1008d8:	89 45 e0             	mov    %eax,-0x20(%ebp)
void print_stackframe(void) 
{
	/* LAB1 YOUR CODE */
	uint32_t eip = read_eip();
	uint32_t ebp = read_ebp();
	while(ebp != 0)
  1008db:	83 7d e0 00          	cmpl   $0x0,-0x20(%ebp)
  1008df:	75 90                	jne    100871 <print_stackframe+0x1e>
		cprintf("ebp:0x%08x eip:0x%08x args:0x%08x 0x%08x 0x%08x 0x%08x\n",*(uint32_t *)ebp,(uint32_t *)eip,*((uint32_t *)ebp+2),*((uint32_t *)ebp+3),*((uint32_t *)ebp+4),*((uint32_t *)ebp+5));
		print_debuginfo(eip);
		eip = *((uint32_t *)ebp + 1);
		ebp = *(uint32_t *)(ebp);
	}
}
  1008e1:	83 c4 3c             	add    $0x3c,%esp
  1008e4:	5b                   	pop    %ebx
  1008e5:	5e                   	pop    %esi
  1008e6:	5f                   	pop    %edi
  1008e7:	5d                   	pop    %ebp
  1008e8:	c3                   	ret    
  1008e9:	00 00                	add    %al,(%eax)
	...

001008ec <parse>:
#define MAXARGS			16
#define WHITESPACE		" \t\n\r"

/* parse - parse the command buffer into whitespace-separated arguments */
static int
parse(char *buf, char **argv) {
  1008ec:	55                   	push   %ebp
  1008ed:	89 e5                	mov    %esp,%ebp
  1008ef:	83 ec 28             	sub    $0x28,%esp
	int argc = 0;
  1008f2:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
	while (1) {
		// find global whitespace
		while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) {
  1008f9:	eb 0a                	jmp    100905 <parse+0x19>
			*buf ++ = '\0';
  1008fb:	8b 45 08             	mov    0x8(%ebp),%eax
  1008fe:	c6 00 00             	movb   $0x0,(%eax)
  100901:	83 45 08 01          	addl   $0x1,0x8(%ebp)
static int
parse(char *buf, char **argv) {
	int argc = 0;
	while (1) {
		// find global whitespace
		while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) {
  100905:	8b 45 08             	mov    0x8(%ebp),%eax
  100908:	0f b6 00             	movzbl (%eax),%eax
  10090b:	84 c0                	test   %al,%al
  10090d:	74 1d                	je     10092c <parse+0x40>
  10090f:	8b 45 08             	mov    0x8(%ebp),%eax
  100912:	0f b6 00             	movzbl (%eax),%eax
  100915:	0f be c0             	movsbl %al,%eax
  100918:	89 44 24 04          	mov    %eax,0x4(%esp)
  10091c:	c7 04 24 f0 20 10 00 	movl   $0x1020f0,(%esp)
  100923:	e8 d0 12 00 00       	call   101bf8 <strchr>
  100928:	85 c0                	test   %eax,%eax
  10092a:	75 cf                	jne    1008fb <parse+0xf>
			*buf ++ = '\0';
		}
		if (*buf == '\0') {
  10092c:	8b 45 08             	mov    0x8(%ebp),%eax
  10092f:	0f b6 00             	movzbl (%eax),%eax
  100932:	84 c0                	test   %al,%al
  100934:	75 05                	jne    10093b <parse+0x4f>
		argv[argc ++] = buf;
		while (*buf != '\0' && strchr(WHITESPACE, *buf) == NULL) {
			buf ++;
		}
	}
	return argc;
  100936:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  100939:	c9                   	leave  
  10093a:	c3                   	ret    
		if (*buf == '\0') {
			break;
		}

		// save and scan past next arg
		if (argc == MAXARGS - 1) {
  10093b:	83 7d f4 0f          	cmpl   $0xf,-0xc(%ebp)
  10093f:	75 14                	jne    100955 <parse+0x69>
			cprintf("Too many arguments (max %d).\n", MAXARGS);
  100941:	c7 44 24 04 10 00 00 	movl   $0x10,0x4(%esp)
  100948:	00 
  100949:	c7 04 24 f5 20 10 00 	movl   $0x1020f5,(%esp)
  100950:	e8 a7 f8 ff ff       	call   1001fc <cprintf>
		}
		argv[argc ++] = buf;
  100955:	8b 45 f4             	mov    -0xc(%ebp),%eax
  100958:	c1 e0 02             	shl    $0x2,%eax
  10095b:	03 45 0c             	add    0xc(%ebp),%eax
  10095e:	8b 55 08             	mov    0x8(%ebp),%edx
  100961:	89 10                	mov    %edx,(%eax)
  100963:	83 45 f4 01          	addl   $0x1,-0xc(%ebp)
		while (*buf != '\0' && strchr(WHITESPACE, *buf) == NULL) {
  100967:	eb 04                	jmp    10096d <parse+0x81>
			buf ++;
  100969:	83 45 08 01          	addl   $0x1,0x8(%ebp)
		// save and scan past next arg
		if (argc == MAXARGS - 1) {
			cprintf("Too many arguments (max %d).\n", MAXARGS);
		}
		argv[argc ++] = buf;
		while (*buf != '\0' && strchr(WHITESPACE, *buf) == NULL) {
  10096d:	8b 45 08             	mov    0x8(%ebp),%eax
  100970:	0f b6 00             	movzbl (%eax),%eax
  100973:	84 c0                	test   %al,%al
  100975:	74 1d                	je     100994 <parse+0xa8>
  100977:	8b 45 08             	mov    0x8(%ebp),%eax
  10097a:	0f b6 00             	movzbl (%eax),%eax
  10097d:	0f be c0             	movsbl %al,%eax
  100980:	89 44 24 04          	mov    %eax,0x4(%esp)
  100984:	c7 04 24 f0 20 10 00 	movl   $0x1020f0,(%esp)
  10098b:	e8 68 12 00 00       	call   101bf8 <strchr>
  100990:	85 c0                	test   %eax,%eax
  100992:	74 d5                	je     100969 <parse+0x7d>
			buf ++;
		}
	}
  100994:	90                   	nop
static int
parse(char *buf, char **argv) {
	int argc = 0;
	while (1) {
		// find global whitespace
		while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) {
  100995:	e9 6b ff ff ff       	jmp    100905 <parse+0x19>

0010099a <runcmd>:
/* *
 * runcmd - parse the input string, split it into separated arguments
 * and then lookup and invoke some related commands/
 * */
static int
runcmd(char *buf, struct trapframe *tf) {
  10099a:	55                   	push   %ebp
  10099b:	89 e5                	mov    %esp,%ebp
  10099d:	83 ec 68             	sub    $0x68,%esp
	char *argv[MAXARGS];
	int argc = parse(buf, argv);
  1009a0:	8d 45 b0             	lea    -0x50(%ebp),%eax
  1009a3:	89 44 24 04          	mov    %eax,0x4(%esp)
  1009a7:	8b 45 08             	mov    0x8(%ebp),%eax
  1009aa:	89 04 24             	mov    %eax,(%esp)
  1009ad:	e8 3a ff ff ff       	call   1008ec <parse>
  1009b2:	89 45 f0             	mov    %eax,-0x10(%ebp)
	if (argc == 0) {
  1009b5:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  1009b9:	75 0a                	jne    1009c5 <runcmd+0x2b>
		return 0;
  1009bb:	b8 00 00 00 00       	mov    $0x0,%eax
  1009c0:	e9 82 00 00 00       	jmp    100a47 <runcmd+0xad>
	}
	int i;
	for (i = 0; i < NCOMMANDS; i ++) {
  1009c5:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  1009cc:	eb 59                	jmp    100a27 <runcmd+0x8d>
		if (strcmp(commands[i].name, argv[0]) == 0) {
  1009ce:	8b 4d b0             	mov    -0x50(%ebp),%ecx
  1009d1:	8b 55 f4             	mov    -0xc(%ebp),%edx
  1009d4:	89 d0                	mov    %edx,%eax
  1009d6:	01 c0                	add    %eax,%eax
  1009d8:	01 d0                	add    %edx,%eax
  1009da:	c1 e0 02             	shl    $0x2,%eax
  1009dd:	8b 80 00 90 10 00    	mov    0x109000(%eax),%eax
  1009e3:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  1009e7:	89 04 24             	mov    %eax,(%esp)
  1009ea:	e8 68 11 00 00       	call   101b57 <strcmp>
  1009ef:	85 c0                	test   %eax,%eax
  1009f1:	75 30                	jne    100a23 <runcmd+0x89>
			return commands[i].func(argc - 1, argv + 1, tf);
  1009f3:	8b 55 f4             	mov    -0xc(%ebp),%edx
  1009f6:	89 d0                	mov    %edx,%eax
  1009f8:	01 c0                	add    %eax,%eax
  1009fa:	01 d0                	add    %edx,%eax
  1009fc:	c1 e0 02             	shl    $0x2,%eax
  1009ff:	8b 90 08 90 10 00    	mov    0x109008(%eax),%edx
  100a05:	8b 45 f0             	mov    -0x10(%ebp),%eax
  100a08:	8d 48 ff             	lea    -0x1(%eax),%ecx
  100a0b:	8b 45 0c             	mov    0xc(%ebp),%eax
  100a0e:	89 44 24 08          	mov    %eax,0x8(%esp)
  100a12:	8d 45 b0             	lea    -0x50(%ebp),%eax
  100a15:	83 c0 04             	add    $0x4,%eax
  100a18:	89 44 24 04          	mov    %eax,0x4(%esp)
  100a1c:	89 0c 24             	mov    %ecx,(%esp)
  100a1f:	ff d2                	call   *%edx
  100a21:	eb 24                	jmp    100a47 <runcmd+0xad>
	int argc = parse(buf, argv);
	if (argc == 0) {
		return 0;
	}
	int i;
	for (i = 0; i < NCOMMANDS; i ++) {
  100a23:	83 45 f4 01          	addl   $0x1,-0xc(%ebp)
  100a27:	8b 45 f4             	mov    -0xc(%ebp),%eax
  100a2a:	83 f8 02             	cmp    $0x2,%eax
  100a2d:	76 9f                	jbe    1009ce <runcmd+0x34>
		if (strcmp(commands[i].name, argv[0]) == 0) {
			return commands[i].func(argc - 1, argv + 1, tf);
		}
	}
	cprintf("Unknown command '%s'\n", argv[0]);
  100a2f:	8b 45 b0             	mov    -0x50(%ebp),%eax
  100a32:	89 44 24 04          	mov    %eax,0x4(%esp)
  100a36:	c7 04 24 13 21 10 00 	movl   $0x102113,(%esp)
  100a3d:	e8 ba f7 ff ff       	call   1001fc <cprintf>
	return 0;
  100a42:	b8 00 00 00 00       	mov    $0x0,%eax
}
  100a47:	c9                   	leave  
  100a48:	c3                   	ret    

00100a49 <monitor>:

/***** Implementations of basic kernel monitor commands *****/

void
monitor(struct trapframe *tf) {
  100a49:	55                   	push   %ebp
  100a4a:	89 e5                	mov    %esp,%ebp
  100a4c:	83 ec 28             	sub    $0x28,%esp
	cprintf("Welcome to the kernel debug monitor!!\n");
  100a4f:	c7 04 24 2c 21 10 00 	movl   $0x10212c,(%esp)
  100a56:	e8 a1 f7 ff ff       	call   1001fc <cprintf>
	cprintf("Type 'help' for a list of commands.\n");
  100a5b:	c7 04 24 54 21 10 00 	movl   $0x102154,(%esp)
  100a62:	e8 95 f7 ff ff       	call   1001fc <cprintf>
  100a67:	eb 04                	jmp    100a6d <monitor+0x24>
		if ((buf = readline("K> ")) != NULL) {
			if (runcmd(buf, tf) < 0) {
				break;
			}
		}
	}
  100a69:	90                   	nop
  100a6a:	eb 01                	jmp    100a6d <monitor+0x24>
  100a6c:	90                   	nop
	cprintf("Welcome to the kernel debug monitor!!\n");
	cprintf("Type 'help' for a list of commands.\n");

	char *buf;
	while (1) {
		if ((buf = readline("K> ")) != NULL) {
  100a6d:	c7 04 24 79 21 10 00 	movl   $0x102179,(%esp)
  100a74:	e8 77 f6 ff ff       	call   1000f0 <readline>
  100a79:	89 45 f4             	mov    %eax,-0xc(%ebp)
  100a7c:	83 7d f4 00          	cmpl   $0x0,-0xc(%ebp)
  100a80:	74 e7                	je     100a69 <monitor+0x20>
			if (runcmd(buf, tf) < 0) {
  100a82:	8b 45 08             	mov    0x8(%ebp),%eax
  100a85:	89 44 24 04          	mov    %eax,0x4(%esp)
  100a89:	8b 45 f4             	mov    -0xc(%ebp),%eax
  100a8c:	89 04 24             	mov    %eax,(%esp)
  100a8f:	e8 06 ff ff ff       	call   10099a <runcmd>
  100a94:	85 c0                	test   %eax,%eax
  100a96:	79 d4                	jns    100a6c <monitor+0x23>
				break;
			}
		}
	}
}
  100a98:	90                   	nop
  100a99:	c9                   	leave  
  100a9a:	c3                   	ret    

00100a9b <mon_help>:

/* mon_help - print the information about mon_* functions */
int
mon_help(int argc, char **argv, struct trapframe *tf) {
  100a9b:	55                   	push   %ebp
  100a9c:	89 e5                	mov    %esp,%ebp
  100a9e:	83 ec 28             	sub    $0x28,%esp
	int i;
	for (i = 0; i < NCOMMANDS; i ++) {
  100aa1:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  100aa8:	eb 3c                	jmp    100ae6 <mon_help+0x4b>
		cprintf("%s - %s\n", commands[i].name, commands[i].desc);
  100aaa:	8b 55 f4             	mov    -0xc(%ebp),%edx
  100aad:	89 d0                	mov    %edx,%eax
  100aaf:	01 c0                	add    %eax,%eax
  100ab1:	01 d0                	add    %edx,%eax
  100ab3:	c1 e0 02             	shl    $0x2,%eax
  100ab6:	8b 88 04 90 10 00    	mov    0x109004(%eax),%ecx
  100abc:	8b 55 f4             	mov    -0xc(%ebp),%edx
  100abf:	89 d0                	mov    %edx,%eax
  100ac1:	01 c0                	add    %eax,%eax
  100ac3:	01 d0                	add    %edx,%eax
  100ac5:	c1 e0 02             	shl    $0x2,%eax
  100ac8:	8b 80 00 90 10 00    	mov    0x109000(%eax),%eax
  100ace:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  100ad2:	89 44 24 04          	mov    %eax,0x4(%esp)
  100ad6:	c7 04 24 7d 21 10 00 	movl   $0x10217d,(%esp)
  100add:	e8 1a f7 ff ff       	call   1001fc <cprintf>

/* mon_help - print the information about mon_* functions */
int
mon_help(int argc, char **argv, struct trapframe *tf) {
	int i;
	for (i = 0; i < NCOMMANDS; i ++) {
  100ae2:	83 45 f4 01          	addl   $0x1,-0xc(%ebp)
  100ae6:	8b 45 f4             	mov    -0xc(%ebp),%eax
  100ae9:	83 f8 02             	cmp    $0x2,%eax
  100aec:	76 bc                	jbe    100aaa <mon_help+0xf>
		cprintf("%s - %s\n", commands[i].name, commands[i].desc);
	}
	return 0;
  100aee:	b8 00 00 00 00       	mov    $0x0,%eax
}
  100af3:	c9                   	leave  
  100af4:	c3                   	ret    

00100af5 <mon_kerninfo>:
/* *
 * mon_kerninfo - call print_kerninfo in kern/debug/kdebug.c to
 * print the memory occupancy in kernel.
 * */
int
mon_kerninfo(int argc, char **argv, struct trapframe *tf) {
  100af5:	55                   	push   %ebp
  100af6:	89 e5                	mov    %esp,%ebp
  100af8:	83 ec 08             	sub    $0x8,%esp
	print_kerninfo();
  100afb:	e8 0c fc ff ff       	call   10070c <print_kerninfo>
	return 0;
  100b00:	b8 00 00 00 00       	mov    $0x0,%eax
}
  100b05:	c9                   	leave  
  100b06:	c3                   	ret    

00100b07 <mon_backtrace>:
/* *
 * mon_backtrace - call print_stackframe in kern/debug/kdebug.c to
 * print a backtrace of the stack.
 * */
int
mon_backtrace(int argc, char **argv, struct trapframe *tf) {
  100b07:	55                   	push   %ebp
  100b08:	89 e5                	mov    %esp,%ebp
  100b0a:	83 ec 08             	sub    $0x8,%esp
	print_stackframe();
  100b0d:	e8 41 fd ff ff       	call   100853 <print_stackframe>
	return 0;
  100b12:	b8 00 00 00 00       	mov    $0x0,%eax
}
  100b17:	c9                   	leave  
  100b18:	c3                   	ret    
  100b19:	00 00                	add    %al,(%eax)
	...

00100b1c <__panic>:
/* *
 * __panic - __panic is called on unresolvable fatal errors. it prints
 * "panic: 'message'", and then enters the kernel monitor.
 * */
void
__panic(const char *file, int line, const char *fmt, ...) {
  100b1c:	55                   	push   %ebp
  100b1d:	89 e5                	mov    %esp,%ebp
  100b1f:	83 ec 28             	sub    $0x28,%esp
	if (is_panic) {
  100b22:	a1 60 99 10 00       	mov    0x109960,%eax
  100b27:	85 c0                	test   %eax,%eax
  100b29:	75 4d                	jne    100b78 <__panic+0x5c>
		goto panic_dead;
	}
	is_panic = 1;
  100b2b:	c7 05 60 99 10 00 01 	movl   $0x1,0x109960
  100b32:	00 00 00 

	// print the 'message'
	va_list ap;
	va_start(ap, fmt);
  100b35:	8d 45 10             	lea    0x10(%ebp),%eax
  100b38:	83 c0 04             	add    $0x4,%eax
  100b3b:	89 45 f4             	mov    %eax,-0xc(%ebp)
	cprintf("kernel panic at %s:%d: ", file, line);
  100b3e:	8b 45 0c             	mov    0xc(%ebp),%eax
  100b41:	89 44 24 08          	mov    %eax,0x8(%esp)
  100b45:	8b 45 08             	mov    0x8(%ebp),%eax
  100b48:	89 44 24 04          	mov    %eax,0x4(%esp)
  100b4c:	c7 04 24 86 21 10 00 	movl   $0x102186,(%esp)
  100b53:	e8 a4 f6 ff ff       	call   1001fc <cprintf>
	vcprintf(fmt, ap);
  100b58:	8b 45 10             	mov    0x10(%ebp),%eax
  100b5b:	8b 55 f4             	mov    -0xc(%ebp),%edx
  100b5e:	89 54 24 04          	mov    %edx,0x4(%esp)
  100b62:	89 04 24             	mov    %eax,(%esp)
  100b65:	e8 5e f6 ff ff       	call   1001c8 <vcprintf>
	cprintf("\n");
  100b6a:	c7 04 24 9e 21 10 00 	movl   $0x10219e,(%esp)
  100b71:	e8 86 f6 ff ff       	call   1001fc <cprintf>
  100b76:	eb 01                	jmp    100b79 <__panic+0x5d>
 * "panic: 'message'", and then enters the kernel monitor.
 * */
void
__panic(const char *file, int line, const char *fmt, ...) {
	if (is_panic) {
		goto panic_dead;
  100b78:	90                   	nop
	cprintf("\n");
	va_end(ap);

panic_dead:
	while (1) {
		monitor(NULL);
  100b79:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  100b80:	e8 c4 fe ff ff       	call   100a49 <monitor>
	}
  100b85:	eb f2                	jmp    100b79 <__panic+0x5d>

00100b87 <__warn>:
}

/* __warn - like panic, but don't */
void
__warn(const char *file, int line, const char *fmt, ...) {
  100b87:	55                   	push   %ebp
  100b88:	89 e5                	mov    %esp,%ebp
  100b8a:	83 ec 28             	sub    $0x28,%esp
	va_list ap;
	va_start(ap, fmt);
  100b8d:	8d 45 10             	lea    0x10(%ebp),%eax
  100b90:	83 c0 04             	add    $0x4,%eax
  100b93:	89 45 f4             	mov    %eax,-0xc(%ebp)
	cprintf("kernel warning at %s:%d: ", file, line);
  100b96:	8b 45 0c             	mov    0xc(%ebp),%eax
  100b99:	89 44 24 08          	mov    %eax,0x8(%esp)
  100b9d:	8b 45 08             	mov    0x8(%ebp),%eax
  100ba0:	89 44 24 04          	mov    %eax,0x4(%esp)
  100ba4:	c7 04 24 a0 21 10 00 	movl   $0x1021a0,(%esp)
  100bab:	e8 4c f6 ff ff       	call   1001fc <cprintf>
	vcprintf(fmt, ap);
  100bb0:	8b 45 10             	mov    0x10(%ebp),%eax
  100bb3:	8b 55 f4             	mov    -0xc(%ebp),%edx
  100bb6:	89 54 24 04          	mov    %edx,0x4(%esp)
  100bba:	89 04 24             	mov    %eax,(%esp)
  100bbd:	e8 06 f6 ff ff       	call   1001c8 <vcprintf>
	cprintf("\n");
  100bc2:	c7 04 24 9e 21 10 00 	movl   $0x10219e,(%esp)
  100bc9:	e8 2e f6 ff ff       	call   1001fc <cprintf>
	va_end(ap);
}
  100bce:	c9                   	leave  
  100bcf:	c3                   	ret    

00100bd0 <is_kernel_panic>:

bool
is_kernel_panic(void) {
  100bd0:	55                   	push   %ebp
  100bd1:	89 e5                	mov    %esp,%ebp
	return is_panic;
  100bd3:	a1 60 99 10 00       	mov    0x109960,%eax
}
  100bd8:	5d                   	pop    %ebp
  100bd9:	c3                   	ret    
	...

00100bdc <delay>:
#include <string.h>
#include <kbdreg.h>

/* stupid I/O delay routine necessitated by historical PC design flaws */
static void
delay(void) {
  100bdc:	55                   	push   %ebp
  100bdd:	89 e5                	mov    %esp,%ebp
  100bdf:	83 ec 10             	sub    $0x10,%esp
  100be2:	66 c7 45 f0 84 00    	movw   $0x84,-0x10(%ebp)
static inline uint32_t read_ebp(void) __attribute__((always_inline));

static inline uint8_t
inb(uint16_t port) {
	uint8_t data;
	asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
  100be8:	0f b7 45 f0          	movzwl -0x10(%ebp),%eax
  100bec:	89 c2                	mov    %eax,%edx
  100bee:	ec                   	in     (%dx),%al
  100bef:	88 45 f3             	mov    %al,-0xd(%ebp)
	return data;
  100bf2:	66 c7 45 f4 84 00    	movw   $0x84,-0xc(%ebp)
static inline uint32_t read_ebp(void) __attribute__((always_inline));

static inline uint8_t
inb(uint16_t port) {
	uint8_t data;
	asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
  100bf8:	0f b7 45 f4          	movzwl -0xc(%ebp),%eax
  100bfc:	89 c2                	mov    %eax,%edx
  100bfe:	ec                   	in     (%dx),%al
  100bff:	88 45 f7             	mov    %al,-0x9(%ebp)
	return data;
  100c02:	66 c7 45 f8 84 00    	movw   $0x84,-0x8(%ebp)
static inline uint32_t read_ebp(void) __attribute__((always_inline));

static inline uint8_t
inb(uint16_t port) {
	uint8_t data;
	asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
  100c08:	0f b7 45 f8          	movzwl -0x8(%ebp),%eax
  100c0c:	89 c2                	mov    %eax,%edx
  100c0e:	ec                   	in     (%dx),%al
  100c0f:	88 45 fb             	mov    %al,-0x5(%ebp)
	return data;
  100c12:	66 c7 45 fc 84 00    	movw   $0x84,-0x4(%ebp)
static inline uint32_t read_ebp(void) __attribute__((always_inline));

static inline uint8_t
inb(uint16_t port) {
	uint8_t data;
	asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
  100c18:	0f b7 45 fc          	movzwl -0x4(%ebp),%eax
  100c1c:	89 c2                	mov    %eax,%edx
  100c1e:	ec                   	in     (%dx),%al
  100c1f:	88 45 ff             	mov    %al,-0x1(%ebp)
	inb(0x84);
	inb(0x84);
	inb(0x84);
	inb(0x84);
}
  100c22:	c9                   	leave  
  100c23:	c3                   	ret    

00100c24 <cga_init>:
static uint16_t addr_6845;

/* TEXT-mode CGA/VGA display output */

static void
cga_init(void) {
  100c24:	55                   	push   %ebp
  100c25:	89 e5                	mov    %esp,%ebp
  100c27:	83 ec 20             	sub    $0x20,%esp
	volatile uint16_t *cp = (uint16_t *)CGA_BUF;
  100c2a:	c7 45 e4 00 80 0b 00 	movl   $0xb8000,-0x1c(%ebp)
	uint16_t was = *cp;
  100c31:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  100c34:	0f b7 00             	movzwl (%eax),%eax
  100c37:	66 89 45 ea          	mov    %ax,-0x16(%ebp)
	*cp = (uint16_t) 0xA55A;
  100c3b:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  100c3e:	66 c7 00 5a a5       	movw   $0xa55a,(%eax)
	if (*cp != 0xA55A) {
  100c43:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  100c46:	0f b7 00             	movzwl (%eax),%eax
  100c49:	66 3d 5a a5          	cmp    $0xa55a,%ax
  100c4d:	74 12                	je     100c61 <cga_init+0x3d>
		cp = (uint16_t*)MONO_BUF;
  100c4f:	c7 45 e4 00 00 0b 00 	movl   $0xb0000,-0x1c(%ebp)
		addr_6845 = MONO_BASE;
  100c56:	66 c7 05 86 99 10 00 	movw   $0x3b4,0x109986
  100c5d:	b4 03 
  100c5f:	eb 13                	jmp    100c74 <cga_init+0x50>
	} else {
		*cp = was;
  100c61:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  100c64:	0f b7 55 ea          	movzwl -0x16(%ebp),%edx
  100c68:	66 89 10             	mov    %dx,(%eax)
		addr_6845 = CGA_BASE;
  100c6b:	66 c7 05 86 99 10 00 	movw   $0x3d4,0x109986
  100c72:	d4 03 
	}

	// Extract cursor location
	uint32_t pos;
	outb(addr_6845, 14);
  100c74:	0f b7 05 86 99 10 00 	movzwl 0x109986,%eax
  100c7b:	0f b7 c0             	movzwl %ax,%eax
  100c7e:	66 89 45 f4          	mov    %ax,-0xc(%ebp)
  100c82:	c6 45 f3 0e          	movb   $0xe,-0xd(%ebp)
			: "memory", "cc");
}

static inline void
outb(uint16_t port, uint8_t data) {
	asm volatile ("outb %0, %1" :: "a" (data), "d" (port));
  100c86:	0f b6 45 f3          	movzbl -0xd(%ebp),%eax
  100c8a:	0f b7 55 f4          	movzwl -0xc(%ebp),%edx
  100c8e:	ee                   	out    %al,(%dx)
	pos = inb(addr_6845 + 1) << 8;
  100c8f:	0f b7 05 86 99 10 00 	movzwl 0x109986,%eax
  100c96:	83 c0 01             	add    $0x1,%eax
  100c99:	0f b7 c0             	movzwl %ax,%eax
  100c9c:	66 89 45 f6          	mov    %ax,-0xa(%ebp)
static inline uint32_t read_ebp(void) __attribute__((always_inline));

static inline uint8_t
inb(uint16_t port) {
	uint8_t data;
	asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
  100ca0:	0f b7 45 f6          	movzwl -0xa(%ebp),%eax
  100ca4:	89 c2                	mov    %eax,%edx
  100ca6:	ec                   	in     (%dx),%al
  100ca7:	88 45 f8             	mov    %al,-0x8(%ebp)
	return data;
  100caa:	0f b6 45 f8          	movzbl -0x8(%ebp),%eax
  100cae:	0f b6 c0             	movzbl %al,%eax
  100cb1:	c1 e0 08             	shl    $0x8,%eax
  100cb4:	89 45 ec             	mov    %eax,-0x14(%ebp)
	outb(addr_6845, 15);
  100cb7:	0f b7 05 86 99 10 00 	movzwl 0x109986,%eax
  100cbe:	0f b7 c0             	movzwl %ax,%eax
  100cc1:	66 89 45 fa          	mov    %ax,-0x6(%ebp)
  100cc5:	c6 45 f9 0f          	movb   $0xf,-0x7(%ebp)
			: "memory", "cc");
}

static inline void
outb(uint16_t port, uint8_t data) {
	asm volatile ("outb %0, %1" :: "a" (data), "d" (port));
  100cc9:	0f b6 45 f9          	movzbl -0x7(%ebp),%eax
  100ccd:	0f b7 55 fa          	movzwl -0x6(%ebp),%edx
  100cd1:	ee                   	out    %al,(%dx)
	pos |= inb(addr_6845 + 1);
  100cd2:	0f b7 05 86 99 10 00 	movzwl 0x109986,%eax
  100cd9:	83 c0 01             	add    $0x1,%eax
  100cdc:	0f b7 c0             	movzwl %ax,%eax
  100cdf:	66 89 45 fc          	mov    %ax,-0x4(%ebp)
static inline uint32_t read_ebp(void) __attribute__((always_inline));

static inline uint8_t
inb(uint16_t port) {
	uint8_t data;
	asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
  100ce3:	0f b7 45 fc          	movzwl -0x4(%ebp),%eax
  100ce7:	89 c2                	mov    %eax,%edx
  100ce9:	ec                   	in     (%dx),%al
  100cea:	88 45 ff             	mov    %al,-0x1(%ebp)
	return data;
  100ced:	0f b6 45 ff          	movzbl -0x1(%ebp),%eax
  100cf1:	0f b6 c0             	movzbl %al,%eax
  100cf4:	09 45 ec             	or     %eax,-0x14(%ebp)

	crt_buf = (uint16_t*) cp;
  100cf7:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  100cfa:	a3 80 99 10 00       	mov    %eax,0x109980
	crt_pos = pos;
  100cff:	8b 45 ec             	mov    -0x14(%ebp),%eax
  100d02:	66 a3 84 99 10 00    	mov    %ax,0x109984
}
  100d08:	c9                   	leave  
  100d09:	c3                   	ret    

00100d0a <serial_init>:

static bool serial_exists = 0;

static void
serial_init(void) {
  100d0a:	55                   	push   %ebp
  100d0b:	89 e5                	mov    %esp,%ebp
  100d0d:	83 ec 30             	sub    $0x30,%esp
  100d10:	66 c7 45 da fa 03    	movw   $0x3fa,-0x26(%ebp)
  100d16:	c6 45 d9 00          	movb   $0x0,-0x27(%ebp)
			: "memory", "cc");
}

static inline void
outb(uint16_t port, uint8_t data) {
	asm volatile ("outb %0, %1" :: "a" (data), "d" (port));
  100d1a:	0f b6 45 d9          	movzbl -0x27(%ebp),%eax
  100d1e:	0f b7 55 da          	movzwl -0x26(%ebp),%edx
  100d22:	ee                   	out    %al,(%dx)
  100d23:	66 c7 45 de fb 03    	movw   $0x3fb,-0x22(%ebp)
  100d29:	c6 45 dd 80          	movb   $0x80,-0x23(%ebp)
  100d2d:	0f b6 45 dd          	movzbl -0x23(%ebp),%eax
  100d31:	0f b7 55 de          	movzwl -0x22(%ebp),%edx
  100d35:	ee                   	out    %al,(%dx)
  100d36:	66 c7 45 e2 f8 03    	movw   $0x3f8,-0x1e(%ebp)
  100d3c:	c6 45 e1 0c          	movb   $0xc,-0x1f(%ebp)
  100d40:	0f b6 45 e1          	movzbl -0x1f(%ebp),%eax
  100d44:	0f b7 55 e2          	movzwl -0x1e(%ebp),%edx
  100d48:	ee                   	out    %al,(%dx)
  100d49:	66 c7 45 e6 f9 03    	movw   $0x3f9,-0x1a(%ebp)
  100d4f:	c6 45 e5 00          	movb   $0x0,-0x1b(%ebp)
  100d53:	0f b6 45 e5          	movzbl -0x1b(%ebp),%eax
  100d57:	0f b7 55 e6          	movzwl -0x1a(%ebp),%edx
  100d5b:	ee                   	out    %al,(%dx)
  100d5c:	66 c7 45 ea fb 03    	movw   $0x3fb,-0x16(%ebp)
  100d62:	c6 45 e9 03          	movb   $0x3,-0x17(%ebp)
  100d66:	0f b6 45 e9          	movzbl -0x17(%ebp),%eax
  100d6a:	0f b7 55 ea          	movzwl -0x16(%ebp),%edx
  100d6e:	ee                   	out    %al,(%dx)
  100d6f:	66 c7 45 ee fc 03    	movw   $0x3fc,-0x12(%ebp)
  100d75:	c6 45 ed 00          	movb   $0x0,-0x13(%ebp)
  100d79:	0f b6 45 ed          	movzbl -0x13(%ebp),%eax
  100d7d:	0f b7 55 ee          	movzwl -0x12(%ebp),%edx
  100d81:	ee                   	out    %al,(%dx)
  100d82:	66 c7 45 f2 f9 03    	movw   $0x3f9,-0xe(%ebp)
  100d88:	c6 45 f1 01          	movb   $0x1,-0xf(%ebp)
  100d8c:	0f b6 45 f1          	movzbl -0xf(%ebp),%eax
  100d90:	0f b7 55 f2          	movzwl -0xe(%ebp),%edx
  100d94:	ee                   	out    %al,(%dx)
  100d95:	66 c7 45 f4 fd 03    	movw   $0x3fd,-0xc(%ebp)
static inline uint32_t read_ebp(void) __attribute__((always_inline));

static inline uint8_t
inb(uint16_t port) {
	uint8_t data;
	asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
  100d9b:	0f b7 45 f4          	movzwl -0xc(%ebp),%eax
  100d9f:	89 c2                	mov    %eax,%edx
  100da1:	ec                   	in     (%dx),%al
  100da2:	88 45 f7             	mov    %al,-0x9(%ebp)
	return data;
  100da5:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
	// Enable rcv interrupts
	outb(COM1 + COM_IER, COM_IER_RDI);

	// Clear any preexisting overrun indications and interrupts
	// Serial port doesn't exist if COM_LSR returns 0xFF
	serial_exists = (inb(COM1 + COM_LSR) != 0xFF);
  100da9:	3c ff                	cmp    $0xff,%al
  100dab:	0f 95 c0             	setne  %al
  100dae:	0f b6 c0             	movzbl %al,%eax
  100db1:	a3 88 99 10 00       	mov    %eax,0x109988
  100db6:	66 c7 45 f8 fa 03    	movw   $0x3fa,-0x8(%ebp)
static inline uint32_t read_ebp(void) __attribute__((always_inline));

static inline uint8_t
inb(uint16_t port) {
	uint8_t data;
	asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
  100dbc:	0f b7 45 f8          	movzwl -0x8(%ebp),%eax
  100dc0:	89 c2                	mov    %eax,%edx
  100dc2:	ec                   	in     (%dx),%al
  100dc3:	88 45 fb             	mov    %al,-0x5(%ebp)
	return data;
  100dc6:	66 c7 45 fc f8 03    	movw   $0x3f8,-0x4(%ebp)
static inline uint32_t read_ebp(void) __attribute__((always_inline));

static inline uint8_t
inb(uint16_t port) {
	uint8_t data;
	asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
  100dcc:	0f b7 45 fc          	movzwl -0x4(%ebp),%eax
  100dd0:	89 c2                	mov    %eax,%edx
  100dd2:	ec                   	in     (%dx),%al
  100dd3:	88 45 ff             	mov    %al,-0x1(%ebp)
	(void) inb(COM1+COM_IIR);
	(void) inb(COM1+COM_RX);
}
  100dd6:	c9                   	leave  
  100dd7:	c3                   	ret    

00100dd8 <lpt_putc>:

/* lpt_putc - copy console output to parallel port */
static void
lpt_putc(int c) {
  100dd8:	55                   	push   %ebp
  100dd9:	89 e5                	mov    %esp,%ebp
  100ddb:	83 ec 20             	sub    $0x20,%esp
	int i;
	for (i = 0; !(inb(LPTPORT + 1) & 0x80) && i < 12800; i ++) {
  100dde:	c7 45 ec 00 00 00 00 	movl   $0x0,-0x14(%ebp)
  100de5:	eb 09                	jmp    100df0 <lpt_putc+0x18>
		delay();
  100de7:	e8 f0 fd ff ff       	call   100bdc <delay>

/* lpt_putc - copy console output to parallel port */
static void
lpt_putc(int c) {
	int i;
	for (i = 0; !(inb(LPTPORT + 1) & 0x80) && i < 12800; i ++) {
  100dec:	83 45 ec 01          	addl   $0x1,-0x14(%ebp)
  100df0:	66 c7 45 f2 79 03    	movw   $0x379,-0xe(%ebp)
  100df6:	0f b7 45 f2          	movzwl -0xe(%ebp),%eax
  100dfa:	89 c2                	mov    %eax,%edx
  100dfc:	ec                   	in     (%dx),%al
  100dfd:	88 45 f4             	mov    %al,-0xc(%ebp)
	return data;
  100e00:	0f b6 45 f4          	movzbl -0xc(%ebp),%eax
  100e04:	84 c0                	test   %al,%al
  100e06:	78 09                	js     100e11 <lpt_putc+0x39>
  100e08:	81 7d ec ff 31 00 00 	cmpl   $0x31ff,-0x14(%ebp)
  100e0f:	7e d6                	jle    100de7 <lpt_putc+0xf>
		delay();
	}
	outb(LPTPORT + 0, c);
  100e11:	8b 45 08             	mov    0x8(%ebp),%eax
  100e14:	0f b6 c0             	movzbl %al,%eax
  100e17:	66 c7 45 f6 78 03    	movw   $0x378,-0xa(%ebp)
  100e1d:	88 45 f5             	mov    %al,-0xb(%ebp)
			: "memory", "cc");
}

static inline void
outb(uint16_t port, uint8_t data) {
	asm volatile ("outb %0, %1" :: "a" (data), "d" (port));
  100e20:	0f b6 45 f5          	movzbl -0xb(%ebp),%eax
  100e24:	0f b7 55 f6          	movzwl -0xa(%ebp),%edx
  100e28:	ee                   	out    %al,(%dx)
  100e29:	66 c7 45 fa 7a 03    	movw   $0x37a,-0x6(%ebp)
  100e2f:	c6 45 f9 0d          	movb   $0xd,-0x7(%ebp)
  100e33:	0f b6 45 f9          	movzbl -0x7(%ebp),%eax
  100e37:	0f b7 55 fa          	movzwl -0x6(%ebp),%edx
  100e3b:	ee                   	out    %al,(%dx)
  100e3c:	66 c7 45 fe 7a 03    	movw   $0x37a,-0x2(%ebp)
  100e42:	c6 45 fd 08          	movb   $0x8,-0x3(%ebp)
  100e46:	0f b6 45 fd          	movzbl -0x3(%ebp),%eax
  100e4a:	0f b7 55 fe          	movzwl -0x2(%ebp),%edx
  100e4e:	ee                   	out    %al,(%dx)
	outb(LPTPORT + 2, 0x08 | 0x04 | 0x01);
	outb(LPTPORT + 2, 0x08);
}
  100e4f:	c9                   	leave  
  100e50:	c3                   	ret    

00100e51 <cga_putc>:

/* cga_putc - print character to console */
static void
cga_putc(int c) {
  100e51:	55                   	push   %ebp
  100e52:	89 e5                	mov    %esp,%ebp
  100e54:	53                   	push   %ebx
  100e55:	83 ec 34             	sub    $0x34,%esp
	// set black on white
	if (!(c & ~0xFF)) {
  100e58:	8b 45 08             	mov    0x8(%ebp),%eax
  100e5b:	b0 00                	mov    $0x0,%al
  100e5d:	85 c0                	test   %eax,%eax
  100e5f:	75 07                	jne    100e68 <cga_putc+0x17>
		c |= 0x0700;
  100e61:	81 4d 08 00 07 00 00 	orl    $0x700,0x8(%ebp)
	}

	switch (c & 0xff) {
  100e68:	8b 45 08             	mov    0x8(%ebp),%eax
  100e6b:	25 ff 00 00 00       	and    $0xff,%eax
  100e70:	83 f8 0a             	cmp    $0xa,%eax
  100e73:	74 4f                	je     100ec4 <cga_putc+0x73>
  100e75:	83 f8 0d             	cmp    $0xd,%eax
  100e78:	74 5a                	je     100ed4 <cga_putc+0x83>
  100e7a:	83 f8 08             	cmp    $0x8,%eax
  100e7d:	0f 85 8d 00 00 00    	jne    100f10 <cga_putc+0xbf>
	case '\b':
		if (crt_pos > 0) {
  100e83:	0f b7 05 84 99 10 00 	movzwl 0x109984,%eax
  100e8a:	66 85 c0             	test   %ax,%ax
  100e8d:	0f 84 a3 00 00 00    	je     100f36 <cga_putc+0xe5>
			crt_pos --;
  100e93:	0f b7 05 84 99 10 00 	movzwl 0x109984,%eax
  100e9a:	83 e8 01             	sub    $0x1,%eax
  100e9d:	66 a3 84 99 10 00    	mov    %ax,0x109984
			crt_buf[crt_pos] = (c & ~0xff) | ' ';
  100ea3:	a1 80 99 10 00       	mov    0x109980,%eax
  100ea8:	0f b7 15 84 99 10 00 	movzwl 0x109984,%edx
  100eaf:	0f b7 d2             	movzwl %dx,%edx
  100eb2:	01 d2                	add    %edx,%edx
  100eb4:	8d 14 10             	lea    (%eax,%edx,1),%edx
  100eb7:	8b 45 08             	mov    0x8(%ebp),%eax
  100eba:	b0 00                	mov    $0x0,%al
  100ebc:	83 c8 20             	or     $0x20,%eax
  100ebf:	66 89 02             	mov    %ax,(%edx)
		}
		break;
  100ec2:	eb 73                	jmp    100f37 <cga_putc+0xe6>
	case '\n':
		crt_pos += CRT_COLS;
  100ec4:	0f b7 05 84 99 10 00 	movzwl 0x109984,%eax
  100ecb:	83 c0 50             	add    $0x50,%eax
  100ece:	66 a3 84 99 10 00    	mov    %ax,0x109984
	case '\r':
		crt_pos -= (crt_pos % CRT_COLS);
  100ed4:	0f b7 1d 84 99 10 00 	movzwl 0x109984,%ebx
  100edb:	0f b7 0d 84 99 10 00 	movzwl 0x109984,%ecx
  100ee2:	0f b7 c1             	movzwl %cx,%eax
  100ee5:	69 c0 cd cc 00 00    	imul   $0xcccd,%eax,%eax
  100eeb:	c1 e8 10             	shr    $0x10,%eax
  100eee:	89 c2                	mov    %eax,%edx
  100ef0:	66 c1 ea 06          	shr    $0x6,%dx
  100ef4:	89 d0                	mov    %edx,%eax
  100ef6:	c1 e0 02             	shl    $0x2,%eax
  100ef9:	01 d0                	add    %edx,%eax
  100efb:	c1 e0 04             	shl    $0x4,%eax
  100efe:	89 ca                	mov    %ecx,%edx
  100f00:	66 29 c2             	sub    %ax,%dx
  100f03:	89 d8                	mov    %ebx,%eax
  100f05:	66 29 d0             	sub    %dx,%ax
  100f08:	66 a3 84 99 10 00    	mov    %ax,0x109984
		break;
  100f0e:	eb 27                	jmp    100f37 <cga_putc+0xe6>
	default:
		crt_buf[crt_pos ++] = c;     // write the character
  100f10:	8b 15 80 99 10 00    	mov    0x109980,%edx
  100f16:	0f b7 05 84 99 10 00 	movzwl 0x109984,%eax
  100f1d:	0f b7 c8             	movzwl %ax,%ecx
  100f20:	01 c9                	add    %ecx,%ecx
  100f22:	8d 0c 0a             	lea    (%edx,%ecx,1),%ecx
  100f25:	8b 55 08             	mov    0x8(%ebp),%edx
  100f28:	66 89 11             	mov    %dx,(%ecx)
  100f2b:	83 c0 01             	add    $0x1,%eax
  100f2e:	66 a3 84 99 10 00    	mov    %ax,0x109984
  100f34:	eb 01                	jmp    100f37 <cga_putc+0xe6>
	case '\b':
		if (crt_pos > 0) {
			crt_pos --;
			crt_buf[crt_pos] = (c & ~0xff) | ' ';
		}
		break;
  100f36:	90                   	nop
		crt_buf[crt_pos ++] = c;     // write the character
		break;
	}

	// What is the purpose of this?
	if (crt_pos >= CRT_SIZE) {
  100f37:	0f b7 05 84 99 10 00 	movzwl 0x109984,%eax
  100f3e:	66 3d cf 07          	cmp    $0x7cf,%ax
  100f42:	76 5b                	jbe    100f9f <cga_putc+0x14e>
		int i;
		memmove(crt_buf, crt_buf + CRT_COLS, (CRT_SIZE - CRT_COLS) * sizeof(uint16_t));
  100f44:	a1 80 99 10 00       	mov    0x109980,%eax
  100f49:	8d 90 a0 00 00 00    	lea    0xa0(%eax),%edx
  100f4f:	a1 80 99 10 00       	mov    0x109980,%eax
  100f54:	c7 44 24 08 00 0f 00 	movl   $0xf00,0x8(%esp)
  100f5b:	00 
  100f5c:	89 54 24 04          	mov    %edx,0x4(%esp)
  100f60:	89 04 24             	mov    %eax,(%esp)
  100f63:	e8 8a 0e 00 00       	call   101df2 <memmove>
		for (i = CRT_SIZE - CRT_COLS; i < CRT_SIZE; i ++) {
  100f68:	c7 45 e4 80 07 00 00 	movl   $0x780,-0x1c(%ebp)
  100f6f:	eb 15                	jmp    100f86 <cga_putc+0x135>
			crt_buf[i] = 0x0700 | ' ';
  100f71:	a1 80 99 10 00       	mov    0x109980,%eax
  100f76:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  100f79:	01 d2                	add    %edx,%edx
  100f7b:	01 d0                	add    %edx,%eax
  100f7d:	66 c7 00 20 07       	movw   $0x720,(%eax)

	// What is the purpose of this?
	if (crt_pos >= CRT_SIZE) {
		int i;
		memmove(crt_buf, crt_buf + CRT_COLS, (CRT_SIZE - CRT_COLS) * sizeof(uint16_t));
		for (i = CRT_SIZE - CRT_COLS; i < CRT_SIZE; i ++) {
  100f82:	83 45 e4 01          	addl   $0x1,-0x1c(%ebp)
  100f86:	81 7d e4 cf 07 00 00 	cmpl   $0x7cf,-0x1c(%ebp)
  100f8d:	7e e2                	jle    100f71 <cga_putc+0x120>
			crt_buf[i] = 0x0700 | ' ';
		}
		crt_pos -= CRT_COLS;
  100f8f:	0f b7 05 84 99 10 00 	movzwl 0x109984,%eax
  100f96:	83 e8 50             	sub    $0x50,%eax
  100f99:	66 a3 84 99 10 00    	mov    %ax,0x109984
	}

	// move that little blinky thing
	outb(addr_6845, 14);
  100f9f:	0f b7 05 86 99 10 00 	movzwl 0x109986,%eax
  100fa6:	0f b7 c0             	movzwl %ax,%eax
  100fa9:	66 89 45 ea          	mov    %ax,-0x16(%ebp)
  100fad:	c6 45 e9 0e          	movb   $0xe,-0x17(%ebp)
  100fb1:	0f b6 45 e9          	movzbl -0x17(%ebp),%eax
  100fb5:	0f b7 55 ea          	movzwl -0x16(%ebp),%edx
  100fb9:	ee                   	out    %al,(%dx)
	outb(addr_6845 + 1, crt_pos >> 8);
  100fba:	0f b7 05 84 99 10 00 	movzwl 0x109984,%eax
  100fc1:	66 c1 e8 08          	shr    $0x8,%ax
  100fc5:	0f b6 c0             	movzbl %al,%eax
  100fc8:	0f b7 15 86 99 10 00 	movzwl 0x109986,%edx
  100fcf:	83 c2 01             	add    $0x1,%edx
  100fd2:	0f b7 d2             	movzwl %dx,%edx
  100fd5:	66 89 55 ee          	mov    %dx,-0x12(%ebp)
  100fd9:	88 45 ed             	mov    %al,-0x13(%ebp)
  100fdc:	0f b6 45 ed          	movzbl -0x13(%ebp),%eax
  100fe0:	0f b7 55 ee          	movzwl -0x12(%ebp),%edx
  100fe4:	ee                   	out    %al,(%dx)
	outb(addr_6845, 15);
  100fe5:	0f b7 05 86 99 10 00 	movzwl 0x109986,%eax
  100fec:	0f b7 c0             	movzwl %ax,%eax
  100fef:	66 89 45 f2          	mov    %ax,-0xe(%ebp)
  100ff3:	c6 45 f1 0f          	movb   $0xf,-0xf(%ebp)
  100ff7:	0f b6 45 f1          	movzbl -0xf(%ebp),%eax
  100ffb:	0f b7 55 f2          	movzwl -0xe(%ebp),%edx
  100fff:	ee                   	out    %al,(%dx)
	outb(addr_6845 + 1, crt_pos);
  101000:	0f b7 05 84 99 10 00 	movzwl 0x109984,%eax
  101007:	0f b6 c0             	movzbl %al,%eax
  10100a:	0f b7 15 86 99 10 00 	movzwl 0x109986,%edx
  101011:	83 c2 01             	add    $0x1,%edx
  101014:	0f b7 d2             	movzwl %dx,%edx
  101017:	66 89 55 f6          	mov    %dx,-0xa(%ebp)
  10101b:	88 45 f5             	mov    %al,-0xb(%ebp)
  10101e:	0f b6 45 f5          	movzbl -0xb(%ebp),%eax
  101022:	0f b7 55 f6          	movzwl -0xa(%ebp),%edx
  101026:	ee                   	out    %al,(%dx)
}
  101027:	83 c4 34             	add    $0x34,%esp
  10102a:	5b                   	pop    %ebx
  10102b:	5d                   	pop    %ebp
  10102c:	c3                   	ret    

0010102d <serial_putc>:

/* serial_putc - print character to serial port */
static void
serial_putc(int c) {
  10102d:	55                   	push   %ebp
  10102e:	89 e5                	mov    %esp,%ebp
  101030:	83 ec 10             	sub    $0x10,%esp
    int i;
	for (i = 0; !(inb(COM1 + COM_LSR) & COM_LSR_TXRDY) && i < 12800; i ++) {
  101033:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  10103a:	eb 09                	jmp    101045 <serial_putc+0x18>
		delay();
  10103c:	e8 9b fb ff ff       	call   100bdc <delay>

/* serial_putc - print character to serial port */
static void
serial_putc(int c) {
    int i;
	for (i = 0; !(inb(COM1 + COM_LSR) & COM_LSR_TXRDY) && i < 12800; i ++) {
  101041:	83 45 f4 01          	addl   $0x1,-0xc(%ebp)
  101045:	66 c7 45 fa fd 03    	movw   $0x3fd,-0x6(%ebp)
static inline uint32_t read_ebp(void) __attribute__((always_inline));

static inline uint8_t
inb(uint16_t port) {
	uint8_t data;
	asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
  10104b:	0f b7 45 fa          	movzwl -0x6(%ebp),%eax
  10104f:	89 c2                	mov    %eax,%edx
  101051:	ec                   	in     (%dx),%al
  101052:	88 45 fc             	mov    %al,-0x4(%ebp)
	return data;
  101055:	0f b6 45 fc          	movzbl -0x4(%ebp),%eax
  101059:	0f b6 c0             	movzbl %al,%eax
  10105c:	83 e0 20             	and    $0x20,%eax
  10105f:	85 c0                	test   %eax,%eax
  101061:	75 09                	jne    10106c <serial_putc+0x3f>
  101063:	81 7d f4 ff 31 00 00 	cmpl   $0x31ff,-0xc(%ebp)
  10106a:	7e d0                	jle    10103c <serial_putc+0xf>
		delay();
	}
	outb(COM1 + COM_TX, c);
  10106c:	8b 45 08             	mov    0x8(%ebp),%eax
  10106f:	0f b6 c0             	movzbl %al,%eax
  101072:	66 c7 45 fe f8 03    	movw   $0x3f8,-0x2(%ebp)
  101078:	88 45 fd             	mov    %al,-0x3(%ebp)
			: "memory", "cc");
}

static inline void
outb(uint16_t port, uint8_t data) {
	asm volatile ("outb %0, %1" :: "a" (data), "d" (port));
  10107b:	0f b6 45 fd          	movzbl -0x3(%ebp),%eax
  10107f:	0f b7 55 fe          	movzwl -0x2(%ebp),%edx
  101083:	ee                   	out    %al,(%dx)
}
  101084:	c9                   	leave  
  101085:	c3                   	ret    

00101086 <cons_intr>:
/* *
 * cons_intr - called by device interrupt routines to feed input
 * characters into the circular console input buffer.
 * */
static void
cons_intr(int (*proc)(void)) {
  101086:	55                   	push   %ebp
  101087:	89 e5                	mov    %esp,%ebp
  101089:	83 ec 18             	sub    $0x18,%esp
	int c;
	while ((c = (*proc)()) != -1) {
  10108c:	eb 32                	jmp    1010c0 <cons_intr+0x3a>
		if (c != 0) {
  10108e:	83 7d f4 00          	cmpl   $0x0,-0xc(%ebp)
  101092:	74 2c                	je     1010c0 <cons_intr+0x3a>
			cons.buf[cons.wpos ++] = c;
  101094:	a1 a4 9b 10 00       	mov    0x109ba4,%eax
  101099:	8b 55 f4             	mov    -0xc(%ebp),%edx
  10109c:	88 90 a0 99 10 00    	mov    %dl,0x1099a0(%eax)
  1010a2:	83 c0 01             	add    $0x1,%eax
  1010a5:	a3 a4 9b 10 00       	mov    %eax,0x109ba4
			if (cons.wpos == CONSBUFSIZE) {
  1010aa:	a1 a4 9b 10 00       	mov    0x109ba4,%eax
  1010af:	3d 00 02 00 00       	cmp    $0x200,%eax
  1010b4:	75 0a                	jne    1010c0 <cons_intr+0x3a>
				cons.wpos = 0;
  1010b6:	c7 05 a4 9b 10 00 00 	movl   $0x0,0x109ba4
  1010bd:	00 00 00 
 * characters into the circular console input buffer.
 * */
static void
cons_intr(int (*proc)(void)) {
	int c;
	while ((c = (*proc)()) != -1) {
  1010c0:	8b 45 08             	mov    0x8(%ebp),%eax
  1010c3:	ff d0                	call   *%eax
  1010c5:	89 45 f4             	mov    %eax,-0xc(%ebp)
  1010c8:	83 7d f4 ff          	cmpl   $0xffffffff,-0xc(%ebp)
  1010cc:	75 c0                	jne    10108e <cons_intr+0x8>
			if (cons.wpos == CONSBUFSIZE) {
				cons.wpos = 0;
			}
		}
	}
}
  1010ce:	c9                   	leave  
  1010cf:	c3                   	ret    

001010d0 <serial_proc_data>:

/* serial_proc_data - get data from serial port */
static int
serial_proc_data(void) {
  1010d0:	55                   	push   %ebp
  1010d1:	89 e5                	mov    %esp,%ebp
  1010d3:	83 ec 10             	sub    $0x10,%esp
  1010d6:	66 c7 45 f8 fd 03    	movw   $0x3fd,-0x8(%ebp)
static inline uint32_t read_ebp(void) __attribute__((always_inline));

static inline uint8_t
inb(uint16_t port) {
	uint8_t data;
	asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
  1010dc:	0f b7 45 f8          	movzwl -0x8(%ebp),%eax
  1010e0:	89 c2                	mov    %eax,%edx
  1010e2:	ec                   	in     (%dx),%al
  1010e3:	88 45 fb             	mov    %al,-0x5(%ebp)
	return data;
  1010e6:	0f b6 45 fb          	movzbl -0x5(%ebp),%eax
	if (!(inb(COM1 + COM_LSR) & COM_LSR_DATA)) {
  1010ea:	0f b6 c0             	movzbl %al,%eax
  1010ed:	83 e0 01             	and    $0x1,%eax
  1010f0:	85 c0                	test   %eax,%eax
  1010f2:	75 07                	jne    1010fb <serial_proc_data+0x2b>
		return -1;
  1010f4:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  1010f9:	eb 17                	jmp    101112 <serial_proc_data+0x42>
  1010fb:	66 c7 45 fc f8 03    	movw   $0x3f8,-0x4(%ebp)
static inline uint32_t read_ebp(void) __attribute__((always_inline));

static inline uint8_t
inb(uint16_t port) {
	uint8_t data;
	asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
  101101:	0f b7 45 fc          	movzwl -0x4(%ebp),%eax
  101105:	89 c2                	mov    %eax,%edx
  101107:	ec                   	in     (%dx),%al
  101108:	88 45 ff             	mov    %al,-0x1(%ebp)
	return data;
  10110b:	0f b6 45 ff          	movzbl -0x1(%ebp),%eax
	}
	return inb(COM1 + COM_RX);
  10110f:	0f b6 c0             	movzbl %al,%eax
}
  101112:	c9                   	leave  
  101113:	c3                   	ret    

00101114 <serial_intr>:

/* serial_intr - try to feed input characters from serial port */
void
serial_intr(void) {
  101114:	55                   	push   %ebp
  101115:	89 e5                	mov    %esp,%ebp
  101117:	83 ec 18             	sub    $0x18,%esp
	if (serial_exists) {
  10111a:	a1 88 99 10 00       	mov    0x109988,%eax
  10111f:	85 c0                	test   %eax,%eax
  101121:	74 0c                	je     10112f <serial_intr+0x1b>
		cons_intr(serial_proc_data);
  101123:	c7 04 24 d0 10 10 00 	movl   $0x1010d0,(%esp)
  10112a:	e8 57 ff ff ff       	call   101086 <cons_intr>
	}
}
  10112f:	c9                   	leave  
  101130:	c3                   	ret    

00101131 <kbd_proc_data>:
 *
 * The kbd_proc_data() function gets data from the keyboard.
 * If we finish a character, return it, else 0. And return -1 if no data.
 * */
static int
kbd_proc_data(void) {
  101131:	55                   	push   %ebp
  101132:	89 e5                	mov    %esp,%ebp
  101134:	83 ec 28             	sub    $0x28,%esp
  101137:	66 c7 45 ee 64 00    	movw   $0x64,-0x12(%ebp)
static inline uint32_t read_ebp(void) __attribute__((always_inline));

static inline uint8_t
inb(uint16_t port) {
	uint8_t data;
	asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
  10113d:	0f b7 45 ee          	movzwl -0x12(%ebp),%eax
  101141:	89 c2                	mov    %eax,%edx
  101143:	ec                   	in     (%dx),%al
  101144:	88 45 f1             	mov    %al,-0xf(%ebp)
	return data;
  101147:	0f b6 45 f1          	movzbl -0xf(%ebp),%eax
	int c;
	uint8_t data;
	static uint32_t shift;

	if ((inb(KBSTATP) & KBS_DIB) == 0) {
  10114b:	0f b6 c0             	movzbl %al,%eax
  10114e:	83 e0 01             	and    $0x1,%eax
  101151:	85 c0                	test   %eax,%eax
  101153:	75 0a                	jne    10115f <kbd_proc_data+0x2e>
		return -1;
  101155:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  10115a:	e9 5a 01 00 00       	jmp    1012b9 <kbd_proc_data+0x188>
  10115f:	66 c7 45 f2 60 00    	movw   $0x60,-0xe(%ebp)
static inline uint32_t read_ebp(void) __attribute__((always_inline));

static inline uint8_t
inb(uint16_t port) {
	uint8_t data;
	asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
  101165:	0f b7 45 f2          	movzwl -0xe(%ebp),%eax
  101169:	89 c2                	mov    %eax,%edx
  10116b:	ec                   	in     (%dx),%al
  10116c:	88 45 f4             	mov    %al,-0xc(%ebp)
	return data;
  10116f:	0f b6 45 f4          	movzbl -0xc(%ebp),%eax
	}

	data = inb(KBDATAP);
  101173:	88 45 ed             	mov    %al,-0x13(%ebp)

	if (data == 0xE0) {
  101176:	80 7d ed e0          	cmpb   $0xe0,-0x13(%ebp)
  10117a:	75 17                	jne    101193 <kbd_proc_data+0x62>
		// E0 escape character
		shift |= E0ESC;
  10117c:	a1 a8 9b 10 00       	mov    0x109ba8,%eax
  101181:	83 c8 40             	or     $0x40,%eax
  101184:	a3 a8 9b 10 00       	mov    %eax,0x109ba8
		return 0;
  101189:	b8 00 00 00 00       	mov    $0x0,%eax
  10118e:	e9 26 01 00 00       	jmp    1012b9 <kbd_proc_data+0x188>
	} else if (data & 0x80) {
  101193:	0f b6 45 ed          	movzbl -0x13(%ebp),%eax
  101197:	84 c0                	test   %al,%al
  101199:	79 47                	jns    1011e2 <kbd_proc_data+0xb1>
		// Key released
		data = (shift & E0ESC ? data : data & 0x7F);
  10119b:	a1 a8 9b 10 00       	mov    0x109ba8,%eax
  1011a0:	83 e0 40             	and    $0x40,%eax
  1011a3:	85 c0                	test   %eax,%eax
  1011a5:	75 09                	jne    1011b0 <kbd_proc_data+0x7f>
  1011a7:	0f b6 45 ed          	movzbl -0x13(%ebp),%eax
  1011ab:	83 e0 7f             	and    $0x7f,%eax
  1011ae:	eb 04                	jmp    1011b4 <kbd_proc_data+0x83>
  1011b0:	0f b6 45 ed          	movzbl -0x13(%ebp),%eax
  1011b4:	88 45 ed             	mov    %al,-0x13(%ebp)
		shift &= ~(shiftcode[data] | E0ESC);
  1011b7:	0f b6 45 ed          	movzbl -0x13(%ebp),%eax
  1011bb:	0f b6 80 40 90 10 00 	movzbl 0x109040(%eax),%eax
  1011c2:	83 c8 40             	or     $0x40,%eax
  1011c5:	0f b6 c0             	movzbl %al,%eax
  1011c8:	f7 d0                	not    %eax
  1011ca:	89 c2                	mov    %eax,%edx
  1011cc:	a1 a8 9b 10 00       	mov    0x109ba8,%eax
  1011d1:	21 d0                	and    %edx,%eax
  1011d3:	a3 a8 9b 10 00       	mov    %eax,0x109ba8
		return 0;
  1011d8:	b8 00 00 00 00       	mov    $0x0,%eax
  1011dd:	e9 d7 00 00 00       	jmp    1012b9 <kbd_proc_data+0x188>
	} else if (shift & E0ESC) {
  1011e2:	a1 a8 9b 10 00       	mov    0x109ba8,%eax
  1011e7:	83 e0 40             	and    $0x40,%eax
  1011ea:	85 c0                	test   %eax,%eax
  1011ec:	74 11                	je     1011ff <kbd_proc_data+0xce>
		// Last character was an E0 escape; or with 0x80
		data |= 0x80;
  1011ee:	80 4d ed 80          	orb    $0x80,-0x13(%ebp)
		shift &= ~E0ESC;
  1011f2:	a1 a8 9b 10 00       	mov    0x109ba8,%eax
  1011f7:	83 e0 bf             	and    $0xffffffbf,%eax
  1011fa:	a3 a8 9b 10 00       	mov    %eax,0x109ba8
	}

	shift |= shiftcode[data];
  1011ff:	0f b6 45 ed          	movzbl -0x13(%ebp),%eax
  101203:	0f b6 80 40 90 10 00 	movzbl 0x109040(%eax),%eax
  10120a:	0f b6 d0             	movzbl %al,%edx
  10120d:	a1 a8 9b 10 00       	mov    0x109ba8,%eax
  101212:	09 d0                	or     %edx,%eax
  101214:	a3 a8 9b 10 00       	mov    %eax,0x109ba8
	shift ^= togglecode[data];
  101219:	0f b6 45 ed          	movzbl -0x13(%ebp),%eax
  10121d:	0f b6 80 40 91 10 00 	movzbl 0x109140(%eax),%eax
  101224:	0f b6 d0             	movzbl %al,%edx
  101227:	a1 a8 9b 10 00       	mov    0x109ba8,%eax
  10122c:	31 d0                	xor    %edx,%eax
  10122e:	a3 a8 9b 10 00       	mov    %eax,0x109ba8

	c = charcode[shift & (CTL | SHIFT)][data];
  101233:	a1 a8 9b 10 00       	mov    0x109ba8,%eax
  101238:	83 e0 03             	and    $0x3,%eax
  10123b:	8b 14 85 40 95 10 00 	mov    0x109540(,%eax,4),%edx
  101242:	0f b6 45 ed          	movzbl -0x13(%ebp),%eax
  101246:	8d 04 02             	lea    (%edx,%eax,1),%eax
  101249:	0f b6 00             	movzbl (%eax),%eax
  10124c:	0f b6 c0             	movzbl %al,%eax
  10124f:	89 45 e8             	mov    %eax,-0x18(%ebp)
	if (shift & CAPSLOCK) {
  101252:	a1 a8 9b 10 00       	mov    0x109ba8,%eax
  101257:	83 e0 08             	and    $0x8,%eax
  10125a:	85 c0                	test   %eax,%eax
  10125c:	74 22                	je     101280 <kbd_proc_data+0x14f>
		if ('a' <= c && c <= 'z')
  10125e:	83 7d e8 60          	cmpl   $0x60,-0x18(%ebp)
  101262:	7e 0c                	jle    101270 <kbd_proc_data+0x13f>
  101264:	83 7d e8 7a          	cmpl   $0x7a,-0x18(%ebp)
  101268:	7f 06                	jg     101270 <kbd_proc_data+0x13f>
			c += 'A' - 'a';
  10126a:	83 6d e8 20          	subl   $0x20,-0x18(%ebp)
	shift |= shiftcode[data];
	shift ^= togglecode[data];

	c = charcode[shift & (CTL | SHIFT)][data];
	if (shift & CAPSLOCK) {
		if ('a' <= c && c <= 'z')
  10126e:	eb 10                	jmp    101280 <kbd_proc_data+0x14f>
			c += 'A' - 'a';
		else if ('A' <= c && c <= 'Z')
  101270:	83 7d e8 40          	cmpl   $0x40,-0x18(%ebp)
  101274:	7e 0a                	jle    101280 <kbd_proc_data+0x14f>
  101276:	83 7d e8 5a          	cmpl   $0x5a,-0x18(%ebp)
  10127a:	7f 04                	jg     101280 <kbd_proc_data+0x14f>
			c += 'a' - 'A';
  10127c:	83 45 e8 20          	addl   $0x20,-0x18(%ebp)
	}

	// Process special keys
	// Ctrl-Alt-Del: reboot
	if (!(~shift & (CTL | ALT)) && c == KEY_DEL) {
  101280:	a1 a8 9b 10 00       	mov    0x109ba8,%eax
  101285:	f7 d0                	not    %eax
  101287:	83 e0 06             	and    $0x6,%eax
  10128a:	85 c0                	test   %eax,%eax
  10128c:	75 28                	jne    1012b6 <kbd_proc_data+0x185>
  10128e:	81 7d e8 e9 00 00 00 	cmpl   $0xe9,-0x18(%ebp)
  101295:	75 1f                	jne    1012b6 <kbd_proc_data+0x185>
		cprintf("Rebooting!\n");
  101297:	c7 04 24 ba 21 10 00 	movl   $0x1021ba,(%esp)
  10129e:	e8 59 ef ff ff       	call   1001fc <cprintf>
  1012a3:	66 c7 45 f6 92 00    	movw   $0x92,-0xa(%ebp)
  1012a9:	c6 45 f5 03          	movb   $0x3,-0xb(%ebp)
			: "memory", "cc");
}

static inline void
outb(uint16_t port, uint8_t data) {
	asm volatile ("outb %0, %1" :: "a" (data), "d" (port));
  1012ad:	0f b6 45 f5          	movzbl -0xb(%ebp),%eax
  1012b1:	0f b7 55 f6          	movzwl -0xa(%ebp),%edx
  1012b5:	ee                   	out    %al,(%dx)
		outb(0x92, 0x3); // courtesy of Chris Frost
	}
	return c;
  1012b6:	8b 45 e8             	mov    -0x18(%ebp),%eax
}
  1012b9:	c9                   	leave  
  1012ba:	c3                   	ret    

001012bb <kbd_intr>:

/* kbd_intr - try to feed input characters from keyboard */
static void
kbd_intr(void) {
  1012bb:	55                   	push   %ebp
  1012bc:	89 e5                	mov    %esp,%ebp
  1012be:	83 ec 18             	sub    $0x18,%esp
	cons_intr(kbd_proc_data);
  1012c1:	c7 04 24 31 11 10 00 	movl   $0x101131,(%esp)
  1012c8:	e8 b9 fd ff ff       	call   101086 <cons_intr>
}
  1012cd:	c9                   	leave  
  1012ce:	c3                   	ret    

001012cf <kbd_init>:

static void
kbd_init(void) {
  1012cf:	55                   	push   %ebp
  1012d0:	89 e5                	mov    %esp,%ebp
  1012d2:	83 ec 08             	sub    $0x8,%esp
	// drain the kbd buffer
	kbd_intr();
  1012d5:	e8 e1 ff ff ff       	call   1012bb <kbd_intr>
}
  1012da:	c9                   	leave  
  1012db:	c3                   	ret    

001012dc <cons_init>:

/* cons_init - initializes the console devices */
void
cons_init(void) {
  1012dc:	55                   	push   %ebp
  1012dd:	89 e5                	mov    %esp,%ebp
  1012df:	83 ec 18             	sub    $0x18,%esp
	cga_init();
  1012e2:	e8 3d f9 ff ff       	call   100c24 <cga_init>
	serial_init();
  1012e7:	e8 1e fa ff ff       	call   100d0a <serial_init>
	kbd_init();
  1012ec:	e8 de ff ff ff       	call   1012cf <kbd_init>
	if (!serial_exists) {
  1012f1:	a1 88 99 10 00       	mov    0x109988,%eax
  1012f6:	85 c0                	test   %eax,%eax
  1012f8:	75 0c                	jne    101306 <cons_init+0x2a>
		cprintf("serial port does not exist!!\n");
  1012fa:	c7 04 24 c6 21 10 00 	movl   $0x1021c6,(%esp)
  101301:	e8 f6 ee ff ff       	call   1001fc <cprintf>
	}
}
  101306:	c9                   	leave  
  101307:	c3                   	ret    

00101308 <cons_putc>:

/* cons_putc - print a single character @c to console devices */
void
cons_putc(int c) {
  101308:	55                   	push   %ebp
  101309:	89 e5                	mov    %esp,%ebp
  10130b:	83 ec 18             	sub    $0x18,%esp
	lpt_putc(c);
  10130e:	8b 45 08             	mov    0x8(%ebp),%eax
  101311:	89 04 24             	mov    %eax,(%esp)
  101314:	e8 bf fa ff ff       	call   100dd8 <lpt_putc>
	cga_putc(c);
  101319:	8b 45 08             	mov    0x8(%ebp),%eax
  10131c:	89 04 24             	mov    %eax,(%esp)
  10131f:	e8 2d fb ff ff       	call   100e51 <cga_putc>
	serial_putc(c);
  101324:	8b 45 08             	mov    0x8(%ebp),%eax
  101327:	89 04 24             	mov    %eax,(%esp)
  10132a:	e8 fe fc ff ff       	call   10102d <serial_putc>
}
  10132f:	c9                   	leave  
  101330:	c3                   	ret    

00101331 <cons_getc>:
/* *
 * cons_getc - return the next input character from console,
 * or 0 if none waiting.
 * */
int
cons_getc(void) {
  101331:	55                   	push   %ebp
  101332:	89 e5                	mov    %esp,%ebp
  101334:	83 ec 18             	sub    $0x18,%esp
	int c;

	// poll for any pending input characters,
	// so that this function works even when interrupts are disabled
	// (e.g., when called from the kernel monitor).
	serial_intr();
  101337:	e8 d8 fd ff ff       	call   101114 <serial_intr>
	kbd_intr();
  10133c:	e8 7a ff ff ff       	call   1012bb <kbd_intr>

	// grab the next character from the input buffer.
	if (cons.rpos != cons.wpos) {
  101341:	8b 15 a0 9b 10 00    	mov    0x109ba0,%edx
  101347:	a1 a4 9b 10 00       	mov    0x109ba4,%eax
  10134c:	39 c2                	cmp    %eax,%edx
  10134e:	74 35                	je     101385 <cons_getc+0x54>
		c = cons.buf[cons.rpos ++];
  101350:	a1 a0 9b 10 00       	mov    0x109ba0,%eax
  101355:	0f b6 90 a0 99 10 00 	movzbl 0x1099a0(%eax),%edx
  10135c:	0f b6 d2             	movzbl %dl,%edx
  10135f:	89 55 f4             	mov    %edx,-0xc(%ebp)
  101362:	83 c0 01             	add    $0x1,%eax
  101365:	a3 a0 9b 10 00       	mov    %eax,0x109ba0
		if (cons.rpos == CONSBUFSIZE) {
  10136a:	a1 a0 9b 10 00       	mov    0x109ba0,%eax
  10136f:	3d 00 02 00 00       	cmp    $0x200,%eax
  101374:	75 0a                	jne    101380 <cons_getc+0x4f>
			cons.rpos = 0;
  101376:	c7 05 a0 9b 10 00 00 	movl   $0x0,0x109ba0
  10137d:	00 00 00 
		}
		return c;
  101380:	8b 45 f4             	mov    -0xc(%ebp),%eax
  101383:	eb 05                	jmp    10138a <cons_getc+0x59>
	}
	return 0;
  101385:	b8 00 00 00 00       	mov    $0x0,%eax
}
  10138a:	c9                   	leave  
  10138b:	c3                   	ret    

0010138c <printnum>:
 * @width: 		maximum number of digits, if the actual width is less than @width, use @padc instead
 * @padc:		character that padded on the left if the actual width is less than @width
 * */
static void
printnum(void (*putch)(int, void*), void *putdat,
		unsigned long long num, unsigned base, int width, int padc) {
  10138c:	55                   	push   %ebp
  10138d:	89 e5                	mov    %esp,%ebp
  10138f:	83 ec 58             	sub    $0x58,%esp
  101392:	8b 45 10             	mov    0x10(%ebp),%eax
  101395:	89 45 d0             	mov    %eax,-0x30(%ebp)
  101398:	8b 45 14             	mov    0x14(%ebp),%eax
  10139b:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	unsigned long long result = num;
  10139e:	8b 45 d0             	mov    -0x30(%ebp),%eax
  1013a1:	8b 55 d4             	mov    -0x2c(%ebp),%edx
  1013a4:	89 45 d8             	mov    %eax,-0x28(%ebp)
  1013a7:	89 55 dc             	mov    %edx,-0x24(%ebp)
	unsigned mod = do_div(result, base);
  1013aa:	8b 45 18             	mov    0x18(%ebp),%eax
  1013ad:	89 45 f4             	mov    %eax,-0xc(%ebp)
  1013b0:	8b 45 d8             	mov    -0x28(%ebp),%eax
  1013b3:	8b 55 dc             	mov    -0x24(%ebp),%edx
  1013b6:	89 45 e8             	mov    %eax,-0x18(%ebp)
  1013b9:	89 55 ec             	mov    %edx,-0x14(%ebp)
  1013bc:	8b 45 ec             	mov    -0x14(%ebp),%eax
  1013bf:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  1013c2:	83 7d ec 00          	cmpl   $0x0,-0x14(%ebp)
  1013c6:	74 1c                	je     1013e4 <printnum+0x58>
  1013c8:	8b 45 ec             	mov    -0x14(%ebp),%eax
  1013cb:	ba 00 00 00 00       	mov    $0x0,%edx
  1013d0:	f7 75 f4             	divl   -0xc(%ebp)
  1013d3:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  1013d6:	8b 45 ec             	mov    -0x14(%ebp),%eax
  1013d9:	ba 00 00 00 00       	mov    $0x0,%edx
  1013de:	f7 75 f4             	divl   -0xc(%ebp)
  1013e1:	89 45 ec             	mov    %eax,-0x14(%ebp)
  1013e4:	8b 45 e8             	mov    -0x18(%ebp),%eax
  1013e7:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  1013ea:	f7 75 f4             	divl   -0xc(%ebp)
  1013ed:	89 45 e8             	mov    %eax,-0x18(%ebp)
  1013f0:	89 55 f0             	mov    %edx,-0x10(%ebp)
  1013f3:	8b 45 e8             	mov    -0x18(%ebp),%eax
  1013f6:	8b 55 ec             	mov    -0x14(%ebp),%edx
  1013f9:	89 45 d8             	mov    %eax,-0x28(%ebp)
  1013fc:	89 55 dc             	mov    %edx,-0x24(%ebp)
  1013ff:	8b 45 f0             	mov    -0x10(%ebp),%eax
  101402:	89 45 e0             	mov    %eax,-0x20(%ebp)

	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  101405:	8b 45 18             	mov    0x18(%ebp),%eax
  101408:	ba 00 00 00 00       	mov    $0x0,%edx
  10140d:	3b 55 d4             	cmp    -0x2c(%ebp),%edx
  101410:	77 56                	ja     101468 <printnum+0xdc>
  101412:	3b 55 d4             	cmp    -0x2c(%ebp),%edx
  101415:	72 05                	jb     10141c <printnum+0x90>
  101417:	3b 45 d0             	cmp    -0x30(%ebp),%eax
  10141a:	77 4c                	ja     101468 <printnum+0xdc>
		printnum(putch, putdat, result, base, width - 1, padc);
  10141c:	8b 45 1c             	mov    0x1c(%ebp),%eax
  10141f:	8d 50 ff             	lea    -0x1(%eax),%edx
  101422:	8b 45 20             	mov    0x20(%ebp),%eax
  101425:	89 44 24 18          	mov    %eax,0x18(%esp)
  101429:	89 54 24 14          	mov    %edx,0x14(%esp)
  10142d:	8b 45 18             	mov    0x18(%ebp),%eax
  101430:	89 44 24 10          	mov    %eax,0x10(%esp)
  101434:	8b 45 d8             	mov    -0x28(%ebp),%eax
  101437:	8b 55 dc             	mov    -0x24(%ebp),%edx
  10143a:	89 44 24 08          	mov    %eax,0x8(%esp)
  10143e:	89 54 24 0c          	mov    %edx,0xc(%esp)
  101442:	8b 45 0c             	mov    0xc(%ebp),%eax
  101445:	89 44 24 04          	mov    %eax,0x4(%esp)
  101449:	8b 45 08             	mov    0x8(%ebp),%eax
  10144c:	89 04 24             	mov    %eax,(%esp)
  10144f:	e8 38 ff ff ff       	call   10138c <printnum>
  101454:	eb 1c                	jmp    101472 <printnum+0xe6>
	} else {
		// print any needed pad characters before first digit
		while (-- width > 0)
			putch(padc, putdat);
  101456:	8b 45 0c             	mov    0xc(%ebp),%eax
  101459:	89 44 24 04          	mov    %eax,0x4(%esp)
  10145d:	8b 45 20             	mov    0x20(%ebp),%eax
  101460:	89 04 24             	mov    %eax,(%esp)
  101463:	8b 45 08             	mov    0x8(%ebp),%eax
  101466:	ff d0                	call   *%eax
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, result, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (-- width > 0)
  101468:	83 6d 1c 01          	subl   $0x1,0x1c(%ebp)
  10146c:	83 7d 1c 00          	cmpl   $0x0,0x1c(%ebp)
  101470:	7f e4                	jg     101456 <printnum+0xca>
			putch(padc, putdat);
	}
	// then print this (the least significant) digit
	putch("0123456789abcdef"[mod], putdat);
  101472:	8b 45 e0             	mov    -0x20(%ebp),%eax
  101475:	0f b6 80 64 22 10 00 	movzbl 0x102264(%eax),%eax
  10147c:	0f be c0             	movsbl %al,%eax
  10147f:	8b 55 0c             	mov    0xc(%ebp),%edx
  101482:	89 54 24 04          	mov    %edx,0x4(%esp)
  101486:	89 04 24             	mov    %eax,(%esp)
  101489:	8b 45 08             	mov    0x8(%ebp),%eax
  10148c:	ff d0                	call   *%eax
}
  10148e:	c9                   	leave  
  10148f:	c3                   	ret    

00101490 <getuint>:
 * getuint - get an unsigned int of various possible sizes from a varargs list
 * @ap:			a varargs list pointer
 * @lflag:		determines the size of the vararg that @ap points to
 * */
static unsigned long long
getuint(va_list *ap, int lflag) {
  101490:	55                   	push   %ebp
  101491:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2) {
  101493:	83 7d 0c 01          	cmpl   $0x1,0xc(%ebp)
  101497:	7e 1c                	jle    1014b5 <getuint+0x25>
		return va_arg(*ap, unsigned long long);
  101499:	8b 45 08             	mov    0x8(%ebp),%eax
  10149c:	8b 00                	mov    (%eax),%eax
  10149e:	8d 50 08             	lea    0x8(%eax),%edx
  1014a1:	8b 45 08             	mov    0x8(%ebp),%eax
  1014a4:	89 10                	mov    %edx,(%eax)
  1014a6:	8b 45 08             	mov    0x8(%ebp),%eax
  1014a9:	8b 00                	mov    (%eax),%eax
  1014ab:	83 e8 08             	sub    $0x8,%eax
  1014ae:	8b 50 04             	mov    0x4(%eax),%edx
  1014b1:	8b 00                	mov    (%eax),%eax
  1014b3:	eb 40                	jmp    1014f5 <getuint+0x65>
	}
	else if (lflag) {
  1014b5:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  1014b9:	74 1e                	je     1014d9 <getuint+0x49>
		return va_arg(*ap, unsigned long);
  1014bb:	8b 45 08             	mov    0x8(%ebp),%eax
  1014be:	8b 00                	mov    (%eax),%eax
  1014c0:	8d 50 04             	lea    0x4(%eax),%edx
  1014c3:	8b 45 08             	mov    0x8(%ebp),%eax
  1014c6:	89 10                	mov    %edx,(%eax)
  1014c8:	8b 45 08             	mov    0x8(%ebp),%eax
  1014cb:	8b 00                	mov    (%eax),%eax
  1014cd:	83 e8 04             	sub    $0x4,%eax
  1014d0:	8b 00                	mov    (%eax),%eax
  1014d2:	ba 00 00 00 00       	mov    $0x0,%edx
  1014d7:	eb 1c                	jmp    1014f5 <getuint+0x65>
	}
	else {
		return va_arg(*ap, unsigned int);
  1014d9:	8b 45 08             	mov    0x8(%ebp),%eax
  1014dc:	8b 00                	mov    (%eax),%eax
  1014de:	8d 50 04             	lea    0x4(%eax),%edx
  1014e1:	8b 45 08             	mov    0x8(%ebp),%eax
  1014e4:	89 10                	mov    %edx,(%eax)
  1014e6:	8b 45 08             	mov    0x8(%ebp),%eax
  1014e9:	8b 00                	mov    (%eax),%eax
  1014eb:	83 e8 04             	sub    $0x4,%eax
  1014ee:	8b 00                	mov    (%eax),%eax
  1014f0:	ba 00 00 00 00       	mov    $0x0,%edx
	}
}
  1014f5:	5d                   	pop    %ebp
  1014f6:	c3                   	ret    

001014f7 <getint>:
 * getint - same as getuint but signed, we can't use getuint because of sign extension
 * @ap:			a varargs list pointer
 * @lflag:		determines the size of the vararg that @ap points to
 * */
static long long
getint(va_list *ap, int lflag) {
  1014f7:	55                   	push   %ebp
  1014f8:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2) {
  1014fa:	83 7d 0c 01          	cmpl   $0x1,0xc(%ebp)
  1014fe:	7e 1c                	jle    10151c <getint+0x25>
		return va_arg(*ap, long long);
  101500:	8b 45 08             	mov    0x8(%ebp),%eax
  101503:	8b 00                	mov    (%eax),%eax
  101505:	8d 50 08             	lea    0x8(%eax),%edx
  101508:	8b 45 08             	mov    0x8(%ebp),%eax
  10150b:	89 10                	mov    %edx,(%eax)
  10150d:	8b 45 08             	mov    0x8(%ebp),%eax
  101510:	8b 00                	mov    (%eax),%eax
  101512:	83 e8 08             	sub    $0x8,%eax
  101515:	8b 50 04             	mov    0x4(%eax),%edx
  101518:	8b 00                	mov    (%eax),%eax
  10151a:	eb 40                	jmp    10155c <getint+0x65>
	}
	else if (lflag) {
  10151c:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  101520:	74 1e                	je     101540 <getint+0x49>
		return va_arg(*ap, long);
  101522:	8b 45 08             	mov    0x8(%ebp),%eax
  101525:	8b 00                	mov    (%eax),%eax
  101527:	8d 50 04             	lea    0x4(%eax),%edx
  10152a:	8b 45 08             	mov    0x8(%ebp),%eax
  10152d:	89 10                	mov    %edx,(%eax)
  10152f:	8b 45 08             	mov    0x8(%ebp),%eax
  101532:	8b 00                	mov    (%eax),%eax
  101534:	83 e8 04             	sub    $0x4,%eax
  101537:	8b 00                	mov    (%eax),%eax
  101539:	89 c2                	mov    %eax,%edx
  10153b:	c1 fa 1f             	sar    $0x1f,%edx
  10153e:	eb 1c                	jmp    10155c <getint+0x65>
	}
	else {
		return va_arg(*ap, int);
  101540:	8b 45 08             	mov    0x8(%ebp),%eax
  101543:	8b 00                	mov    (%eax),%eax
  101545:	8d 50 04             	lea    0x4(%eax),%edx
  101548:	8b 45 08             	mov    0x8(%ebp),%eax
  10154b:	89 10                	mov    %edx,(%eax)
  10154d:	8b 45 08             	mov    0x8(%ebp),%eax
  101550:	8b 00                	mov    (%eax),%eax
  101552:	83 e8 04             	sub    $0x4,%eax
  101555:	8b 00                	mov    (%eax),%eax
  101557:	89 c2                	mov    %eax,%edx
  101559:	c1 fa 1f             	sar    $0x1f,%edx
	}
}
  10155c:	5d                   	pop    %ebp
  10155d:	c3                   	ret    

0010155e <printfmt>:
 * @putch:		specified putch function, print a single character
 * @putdat:		used by @putch function
 * @fmt:		the format string to use
 * */
void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...) {
  10155e:	55                   	push   %ebp
  10155f:	89 e5                	mov    %esp,%ebp
  101561:	83 ec 28             	sub    $0x28,%esp
	va_list ap;

	va_start(ap, fmt);
  101564:	8d 45 10             	lea    0x10(%ebp),%eax
  101567:	83 c0 04             	add    $0x4,%eax
  10156a:	89 45 f4             	mov    %eax,-0xc(%ebp)
	vprintfmt(putch, putdat, fmt, ap);
  10156d:	8b 45 10             	mov    0x10(%ebp),%eax
  101570:	8b 55 f4             	mov    -0xc(%ebp),%edx
  101573:	89 54 24 0c          	mov    %edx,0xc(%esp)
  101577:	89 44 24 08          	mov    %eax,0x8(%esp)
  10157b:	8b 45 0c             	mov    0xc(%ebp),%eax
  10157e:	89 44 24 04          	mov    %eax,0x4(%esp)
  101582:	8b 45 08             	mov    0x8(%ebp),%eax
  101585:	89 04 24             	mov    %eax,(%esp)
  101588:	e8 02 00 00 00       	call   10158f <vprintfmt>
	va_end(ap);
}
  10158d:	c9                   	leave  
  10158e:	c3                   	ret    

0010158f <vprintfmt>:
 *
 * Call this function if you are already dealing with a va_list.
 * Or you probably want printfmt() instead.
 * */
void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap) {
  10158f:	55                   	push   %ebp
  101590:	89 e5                	mov    %esp,%ebp
  101592:	56                   	push   %esi
  101593:	53                   	push   %ebx
  101594:	83 ec 40             	sub    $0x40,%esp
	register int ch, err;
	unsigned long long num;
	int base, width, precision, lflag, altflag;

	while (1) {
		while ((ch = *(unsigned char *)fmt ++) != '%') {
  101597:	eb 17                	jmp    1015b0 <vprintfmt+0x21>
			if (ch == '\0') {
  101599:	85 db                	test   %ebx,%ebx
  10159b:	0f 84 06 04 00 00    	je     1019a7 <vprintfmt+0x418>
				return;
			}
			putch(ch, putdat);
  1015a1:	8b 45 0c             	mov    0xc(%ebp),%eax
  1015a4:	89 44 24 04          	mov    %eax,0x4(%esp)
  1015a8:	89 1c 24             	mov    %ebx,(%esp)
  1015ab:	8b 45 08             	mov    0x8(%ebp),%eax
  1015ae:	ff d0                	call   *%eax
	register int ch, err;
	unsigned long long num;
	int base, width, precision, lflag, altflag;

	while (1) {
		while ((ch = *(unsigned char *)fmt ++) != '%') {
  1015b0:	8b 45 10             	mov    0x10(%ebp),%eax
  1015b3:	0f b6 00             	movzbl (%eax),%eax
  1015b6:	0f b6 d8             	movzbl %al,%ebx
  1015b9:	83 fb 25             	cmp    $0x25,%ebx
  1015bc:	0f 95 c0             	setne  %al
  1015bf:	83 45 10 01          	addl   $0x1,0x10(%ebp)
  1015c3:	84 c0                	test   %al,%al
  1015c5:	75 d2                	jne    101599 <vprintfmt+0xa>
			}
			putch(ch, putdat);
		}

		// Process a %-escape sequence
		char padc = ' ';
  1015c7:	c6 45 f7 20          	movb   $0x20,-0x9(%ebp)
		width = precision = -1;
  1015cb:	c7 45 e8 ff ff ff ff 	movl   $0xffffffff,-0x18(%ebp)
  1015d2:	8b 45 e8             	mov    -0x18(%ebp),%eax
  1015d5:	89 45 e4             	mov    %eax,-0x1c(%ebp)
		lflag = altflag = 0;
  1015d8:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  1015df:	8b 45 f0             	mov    -0x10(%ebp),%eax
  1015e2:	89 45 ec             	mov    %eax,-0x14(%ebp)
  1015e5:	eb 04                	jmp    1015eb <vprintfmt+0x5c>
			goto process_precision;

		case '.':
			if (width < 0)
				width = 0;
			goto reswitch;
  1015e7:	90                   	nop
  1015e8:	eb 01                	jmp    1015eb <vprintfmt+0x5c>
			goto reswitch;

		process_precision:
			if (width < 0)
				width = precision, precision = -1;
			goto reswitch;
  1015ea:	90                   	nop
		char padc = ' ';
		width = precision = -1;
		lflag = altflag = 0;

	reswitch:
		switch (ch = *(unsigned char *)fmt ++) {
  1015eb:	8b 45 10             	mov    0x10(%ebp),%eax
  1015ee:	0f b6 00             	movzbl (%eax),%eax
  1015f1:	0f b6 d8             	movzbl %al,%ebx
  1015f4:	89 d8                	mov    %ebx,%eax
  1015f6:	83 45 10 01          	addl   $0x1,0x10(%ebp)
  1015fa:	83 e8 23             	sub    $0x23,%eax
  1015fd:	83 f8 55             	cmp    $0x55,%eax
  101600:	0f 87 71 03 00 00    	ja     101977 <vprintfmt+0x3e8>
  101606:	8b 04 85 88 22 10 00 	mov    0x102288(,%eax,4),%eax
  10160d:	ff e0                	jmp    *%eax

		// flag to pad on the right
		case '-':
			padc = '-';
  10160f:	c6 45 f7 2d          	movb   $0x2d,-0x9(%ebp)
			goto reswitch;
  101613:	eb d6                	jmp    1015eb <vprintfmt+0x5c>

		// flag to pad with 0's instead of spaces
		case '0':
			padc = '0';
  101615:	c6 45 f7 30          	movb   $0x30,-0x9(%ebp)
			goto reswitch;
  101619:	eb d0                	jmp    1015eb <vprintfmt+0x5c>

		// width field
		case '1' ... '9':
			for (precision = 0; ; ++ fmt) {
  10161b:	c7 45 e8 00 00 00 00 	movl   $0x0,-0x18(%ebp)
				precision = precision * 10 + ch - '0';
  101622:	8b 55 e8             	mov    -0x18(%ebp),%edx
  101625:	89 d0                	mov    %edx,%eax
  101627:	c1 e0 02             	shl    $0x2,%eax
  10162a:	01 d0                	add    %edx,%eax
  10162c:	01 c0                	add    %eax,%eax
  10162e:	01 d8                	add    %ebx,%eax
  101630:	83 e8 30             	sub    $0x30,%eax
  101633:	89 45 e8             	mov    %eax,-0x18(%ebp)
				ch = *fmt;
  101636:	8b 45 10             	mov    0x10(%ebp),%eax
  101639:	0f b6 00             	movzbl (%eax),%eax
  10163c:	0f be d8             	movsbl %al,%ebx
				if (ch < '0' || ch > '9') {
  10163f:	83 fb 2f             	cmp    $0x2f,%ebx
  101642:	7e 43                	jle    101687 <vprintfmt+0xf8>
  101644:	83 fb 39             	cmp    $0x39,%ebx
  101647:	7f 41                	jg     10168a <vprintfmt+0xfb>
			padc = '0';
			goto reswitch;

		// width field
		case '1' ... '9':
			for (precision = 0; ; ++ fmt) {
  101649:	83 45 10 01          	addl   $0x1,0x10(%ebp)
				precision = precision * 10 + ch - '0';
				ch = *fmt;
				if (ch < '0' || ch > '9') {
					break;
				}
			}
  10164d:	eb d3                	jmp    101622 <vprintfmt+0x93>
			goto process_precision;

		case '*':
			precision = va_arg(ap, int);
  10164f:	8b 45 14             	mov    0x14(%ebp),%eax
  101652:	83 c0 04             	add    $0x4,%eax
  101655:	89 45 14             	mov    %eax,0x14(%ebp)
  101658:	8b 45 14             	mov    0x14(%ebp),%eax
  10165b:	83 e8 04             	sub    $0x4,%eax
  10165e:	8b 00                	mov    (%eax),%eax
  101660:	89 45 e8             	mov    %eax,-0x18(%ebp)
			goto process_precision;
  101663:	eb 26                	jmp    10168b <vprintfmt+0xfc>

		case '.':
			if (width < 0)
  101665:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  101669:	0f 89 78 ff ff ff    	jns    1015e7 <vprintfmt+0x58>
				width = 0;
  10166f:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
			goto reswitch;
  101676:	e9 70 ff ff ff       	jmp    1015eb <vprintfmt+0x5c>

		case '#':
			altflag = 1;
  10167b:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)
			goto reswitch;
  101682:	e9 64 ff ff ff       	jmp    1015eb <vprintfmt+0x5c>
				ch = *fmt;
				if (ch < '0' || ch > '9') {
					break;
				}
			}
			goto process_precision;
  101687:	90                   	nop
  101688:	eb 01                	jmp    10168b <vprintfmt+0xfc>
  10168a:	90                   	nop
		case '#':
			altflag = 1;
			goto reswitch;

		process_precision:
			if (width < 0)
  10168b:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  10168f:	0f 89 55 ff ff ff    	jns    1015ea <vprintfmt+0x5b>
				width = precision, precision = -1;
  101695:	8b 45 e8             	mov    -0x18(%ebp),%eax
  101698:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  10169b:	c7 45 e8 ff ff ff ff 	movl   $0xffffffff,-0x18(%ebp)
			goto reswitch;
  1016a2:	e9 44 ff ff ff       	jmp    1015eb <vprintfmt+0x5c>

		// long flag (doubled for long long)
		case 'l':
			lflag ++;
  1016a7:	83 45 ec 01          	addl   $0x1,-0x14(%ebp)
			goto reswitch;
  1016ab:	e9 3b ff ff ff       	jmp    1015eb <vprintfmt+0x5c>

		// character
		case 'c':
			putch(va_arg(ap, int), putdat);
  1016b0:	8b 45 14             	mov    0x14(%ebp),%eax
  1016b3:	83 c0 04             	add    $0x4,%eax
  1016b6:	89 45 14             	mov    %eax,0x14(%ebp)
  1016b9:	8b 45 14             	mov    0x14(%ebp),%eax
  1016bc:	83 e8 04             	sub    $0x4,%eax
  1016bf:	8b 00                	mov    (%eax),%eax
  1016c1:	8b 55 0c             	mov    0xc(%ebp),%edx
  1016c4:	89 54 24 04          	mov    %edx,0x4(%esp)
  1016c8:	89 04 24             	mov    %eax,(%esp)
  1016cb:	8b 45 08             	mov    0x8(%ebp),%eax
  1016ce:	ff d0                	call   *%eax
			break;
  1016d0:	e9 cc 02 00 00       	jmp    1019a1 <vprintfmt+0x412>

		// error message
		case 'e':
			err = va_arg(ap, int);
  1016d5:	8b 45 14             	mov    0x14(%ebp),%eax
  1016d8:	83 c0 04             	add    $0x4,%eax
  1016db:	89 45 14             	mov    %eax,0x14(%ebp)
  1016de:	8b 45 14             	mov    0x14(%ebp),%eax
  1016e1:	83 e8 04             	sub    $0x4,%eax
  1016e4:	8b 18                	mov    (%eax),%ebx
			if (err < 0) {
  1016e6:	85 db                	test   %ebx,%ebx
  1016e8:	79 02                	jns    1016ec <vprintfmt+0x15d>
				err = -err;
  1016ea:	f7 db                	neg    %ebx
			}
			if (err > MAXERROR || (p = error_string[err]) == NULL) {
  1016ec:	83 fb 06             	cmp    $0x6,%ebx
  1016ef:	7f 0d                	jg     1016fe <vprintfmt+0x16f>
  1016f1:	89 d8                	mov    %ebx,%eax
  1016f3:	8b 34 85 48 22 10 00 	mov    0x102248(,%eax,4),%esi
  1016fa:	85 f6                	test   %esi,%esi
  1016fc:	75 24                	jne    101722 <vprintfmt+0x193>
				printfmt(putch, putdat, "error %d", err);
  1016fe:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  101702:	c7 44 24 08 75 22 10 	movl   $0x102275,0x8(%esp)
  101709:	00 
  10170a:	8b 45 0c             	mov    0xc(%ebp),%eax
  10170d:	89 44 24 04          	mov    %eax,0x4(%esp)
  101711:	8b 45 08             	mov    0x8(%ebp),%eax
  101714:	89 04 24             	mov    %eax,(%esp)
  101717:	e8 42 fe ff ff       	call   10155e <printfmt>
		case 'e':
			err = va_arg(ap, int);
			if (err < 0) {
				err = -err;
			}
			if (err > MAXERROR || (p = error_string[err]) == NULL) {
  10171c:	90                   	nop
				printfmt(putch, putdat, "error %d", err);
			}
			else {
				printfmt(putch, putdat, "%s", p);
			}
			break;
  10171d:	e9 7f 02 00 00       	jmp    1019a1 <vprintfmt+0x412>
			}
			if (err > MAXERROR || (p = error_string[err]) == NULL) {
				printfmt(putch, putdat, "error %d", err);
			}
			else {
				printfmt(putch, putdat, "%s", p);
  101722:	89 74 24 0c          	mov    %esi,0xc(%esp)
  101726:	c7 44 24 08 7e 22 10 	movl   $0x10227e,0x8(%esp)
  10172d:	00 
  10172e:	8b 45 0c             	mov    0xc(%ebp),%eax
  101731:	89 44 24 04          	mov    %eax,0x4(%esp)
  101735:	8b 45 08             	mov    0x8(%ebp),%eax
  101738:	89 04 24             	mov    %eax,(%esp)
  10173b:	e8 1e fe ff ff       	call   10155e <printfmt>
			}
			break;
  101740:	e9 5c 02 00 00       	jmp    1019a1 <vprintfmt+0x412>

		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL) {
  101745:	8b 45 14             	mov    0x14(%ebp),%eax
  101748:	83 c0 04             	add    $0x4,%eax
  10174b:	89 45 14             	mov    %eax,0x14(%ebp)
  10174e:	8b 45 14             	mov    0x14(%ebp),%eax
  101751:	83 e8 04             	sub    $0x4,%eax
  101754:	8b 30                	mov    (%eax),%esi
  101756:	85 f6                	test   %esi,%esi
  101758:	75 05                	jne    10175f <vprintfmt+0x1d0>
				p = "(null)";
  10175a:	be 81 22 10 00       	mov    $0x102281,%esi
			}
			if (width > 0 && padc != '-') {
  10175f:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  101763:	7e 7c                	jle    1017e1 <vprintfmt+0x252>
  101765:	80 7d f7 2d          	cmpb   $0x2d,-0x9(%ebp)
  101769:	74 79                	je     1017e4 <vprintfmt+0x255>
				for (width -= strnlen(p, precision); width > 0; width --) {
  10176b:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
  10176e:	8b 45 e8             	mov    -0x18(%ebp),%eax
  101771:	89 44 24 04          	mov    %eax,0x4(%esp)
  101775:	89 34 24             	mov    %esi,(%esp)
  101778:	e8 2e 03 00 00       	call   101aab <strnlen>
  10177d:	89 da                	mov    %ebx,%edx
  10177f:	29 c2                	sub    %eax,%edx
  101781:	89 d0                	mov    %edx,%eax
  101783:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  101786:	eb 17                	jmp    10179f <vprintfmt+0x210>
					putch(padc, putdat);
  101788:	0f be 45 f7          	movsbl -0x9(%ebp),%eax
  10178c:	8b 55 0c             	mov    0xc(%ebp),%edx
  10178f:	89 54 24 04          	mov    %edx,0x4(%esp)
  101793:	89 04 24             	mov    %eax,(%esp)
  101796:	8b 45 08             	mov    0x8(%ebp),%eax
  101799:	ff d0                	call   *%eax
		case 's':
			if ((p = va_arg(ap, char *)) == NULL) {
				p = "(null)";
			}
			if (width > 0 && padc != '-') {
				for (width -= strnlen(p, precision); width > 0; width --) {
  10179b:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  10179f:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  1017a3:	7f e3                	jg     101788 <vprintfmt+0x1f9>
					putch(padc, putdat);
				}
			}
			for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
  1017a5:	eb 3e                	jmp    1017e5 <vprintfmt+0x256>
				if (altflag && (ch < ' ' || ch > '~')) {
  1017a7:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  1017ab:	74 1f                	je     1017cc <vprintfmt+0x23d>
  1017ad:	83 fb 1f             	cmp    $0x1f,%ebx
  1017b0:	7e 05                	jle    1017b7 <vprintfmt+0x228>
  1017b2:	83 fb 7e             	cmp    $0x7e,%ebx
  1017b5:	7e 15                	jle    1017cc <vprintfmt+0x23d>
					putch('?', putdat);
  1017b7:	8b 45 0c             	mov    0xc(%ebp),%eax
  1017ba:	89 44 24 04          	mov    %eax,0x4(%esp)
  1017be:	c7 04 24 3f 00 00 00 	movl   $0x3f,(%esp)
  1017c5:	8b 45 08             	mov    0x8(%ebp),%eax
  1017c8:	ff d0                	call   *%eax
				for (width -= strnlen(p, precision); width > 0; width --) {
					putch(padc, putdat);
				}
			}
			for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
				if (altflag && (ch < ' ' || ch > '~')) {
  1017ca:	eb 0f                	jmp    1017db <vprintfmt+0x24c>
					putch('?', putdat);
				}
				else {
					putch(ch, putdat);
  1017cc:	8b 45 0c             	mov    0xc(%ebp),%eax
  1017cf:	89 44 24 04          	mov    %eax,0x4(%esp)
  1017d3:	89 1c 24             	mov    %ebx,(%esp)
  1017d6:	8b 45 08             	mov    0x8(%ebp),%eax
  1017d9:	ff d0                	call   *%eax
			if (width > 0 && padc != '-') {
				for (width -= strnlen(p, precision); width > 0; width --) {
					putch(padc, putdat);
				}
			}
			for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
  1017db:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  1017df:	eb 04                	jmp    1017e5 <vprintfmt+0x256>
  1017e1:	90                   	nop
  1017e2:	eb 01                	jmp    1017e5 <vprintfmt+0x256>
  1017e4:	90                   	nop
  1017e5:	0f b6 06             	movzbl (%esi),%eax
  1017e8:	0f be d8             	movsbl %al,%ebx
  1017eb:	85 db                	test   %ebx,%ebx
  1017ed:	0f 95 c0             	setne  %al
  1017f0:	83 c6 01             	add    $0x1,%esi
  1017f3:	84 c0                	test   %al,%al
  1017f5:	74 29                	je     101820 <vprintfmt+0x291>
  1017f7:	83 7d e8 00          	cmpl   $0x0,-0x18(%ebp)
  1017fb:	78 aa                	js     1017a7 <vprintfmt+0x218>
  1017fd:	83 6d e8 01          	subl   $0x1,-0x18(%ebp)
  101801:	83 7d e8 00          	cmpl   $0x0,-0x18(%ebp)
  101805:	79 a0                	jns    1017a7 <vprintfmt+0x218>
				}
				else {
					putch(ch, putdat);
				}
			}
			for (; width > 0; width --) {
  101807:	eb 17                	jmp    101820 <vprintfmt+0x291>
				putch(' ', putdat);
  101809:	8b 45 0c             	mov    0xc(%ebp),%eax
  10180c:	89 44 24 04          	mov    %eax,0x4(%esp)
  101810:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  101817:	8b 45 08             	mov    0x8(%ebp),%eax
  10181a:	ff d0                	call   *%eax
				}
				else {
					putch(ch, putdat);
				}
			}
			for (; width > 0; width --) {
  10181c:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  101820:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  101824:	7f e3                	jg     101809 <vprintfmt+0x27a>
				putch(' ', putdat);
			}
			break;
  101826:	e9 76 01 00 00       	jmp    1019a1 <vprintfmt+0x412>

		// (signed) decimal
		case 'd':
			num = getint(&ap, lflag);
  10182b:	8b 45 ec             	mov    -0x14(%ebp),%eax
  10182e:	89 44 24 04          	mov    %eax,0x4(%esp)
  101832:	8d 45 14             	lea    0x14(%ebp),%eax
  101835:	89 04 24             	mov    %eax,(%esp)
  101838:	e8 ba fc ff ff       	call   1014f7 <getint>
  10183d:	89 45 d8             	mov    %eax,-0x28(%ebp)
  101840:	89 55 dc             	mov    %edx,-0x24(%ebp)
			if ((long long)num < 0) {
  101843:	8b 45 d8             	mov    -0x28(%ebp),%eax
  101846:	8b 55 dc             	mov    -0x24(%ebp),%edx
  101849:	85 d2                	test   %edx,%edx
  10184b:	79 26                	jns    101873 <vprintfmt+0x2e4>
				putch('-', putdat);
  10184d:	8b 45 0c             	mov    0xc(%ebp),%eax
  101850:	89 44 24 04          	mov    %eax,0x4(%esp)
  101854:	c7 04 24 2d 00 00 00 	movl   $0x2d,(%esp)
  10185b:	8b 45 08             	mov    0x8(%ebp),%eax
  10185e:	ff d0                	call   *%eax
				num = -(long long)num;
  101860:	8b 45 d8             	mov    -0x28(%ebp),%eax
  101863:	8b 55 dc             	mov    -0x24(%ebp),%edx
  101866:	f7 d8                	neg    %eax
  101868:	83 d2 00             	adc    $0x0,%edx
  10186b:	f7 da                	neg    %edx
  10186d:	89 45 d8             	mov    %eax,-0x28(%ebp)
  101870:	89 55 dc             	mov    %edx,-0x24(%ebp)
			}
			base = 10;
  101873:	c7 45 e0 0a 00 00 00 	movl   $0xa,-0x20(%ebp)
			goto number;
  10187a:	e9 af 00 00 00       	jmp    10192e <vprintfmt+0x39f>

		// unsigned decimal
		case 'u':
			num = getuint(&ap, lflag);
  10187f:	8b 45 ec             	mov    -0x14(%ebp),%eax
  101882:	89 44 24 04          	mov    %eax,0x4(%esp)
  101886:	8d 45 14             	lea    0x14(%ebp),%eax
  101889:	89 04 24             	mov    %eax,(%esp)
  10188c:	e8 ff fb ff ff       	call   101490 <getuint>
  101891:	89 45 d8             	mov    %eax,-0x28(%ebp)
  101894:	89 55 dc             	mov    %edx,-0x24(%ebp)
			base = 10;
  101897:	c7 45 e0 0a 00 00 00 	movl   $0xa,-0x20(%ebp)
			goto number;
  10189e:	e9 8b 00 00 00       	jmp    10192e <vprintfmt+0x39f>

		// (unsigned) octal
		case 'o':
			num = getuint(&ap, lflag);
  1018a3:	8b 45 ec             	mov    -0x14(%ebp),%eax
  1018a6:	89 44 24 04          	mov    %eax,0x4(%esp)
  1018aa:	8d 45 14             	lea    0x14(%ebp),%eax
  1018ad:	89 04 24             	mov    %eax,(%esp)
  1018b0:	e8 db fb ff ff       	call   101490 <getuint>
  1018b5:	89 45 d8             	mov    %eax,-0x28(%ebp)
  1018b8:	89 55 dc             	mov    %edx,-0x24(%ebp)
			base = 8;
  1018bb:	c7 45 e0 08 00 00 00 	movl   $0x8,-0x20(%ebp)
			goto number;
  1018c2:	eb 6a                	jmp    10192e <vprintfmt+0x39f>

		// pointer
		case 'p':
			putch('0', putdat);
  1018c4:	8b 45 0c             	mov    0xc(%ebp),%eax
  1018c7:	89 44 24 04          	mov    %eax,0x4(%esp)
  1018cb:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  1018d2:	8b 45 08             	mov    0x8(%ebp),%eax
  1018d5:	ff d0                	call   *%eax
			putch('x', putdat);
  1018d7:	8b 45 0c             	mov    0xc(%ebp),%eax
  1018da:	89 44 24 04          	mov    %eax,0x4(%esp)
  1018de:	c7 04 24 78 00 00 00 	movl   $0x78,(%esp)
  1018e5:	8b 45 08             	mov    0x8(%ebp),%eax
  1018e8:	ff d0                	call   *%eax
			num = (unsigned long long)(uintptr_t)va_arg(ap, void *);
  1018ea:	8b 45 14             	mov    0x14(%ebp),%eax
  1018ed:	83 c0 04             	add    $0x4,%eax
  1018f0:	89 45 14             	mov    %eax,0x14(%ebp)
  1018f3:	8b 45 14             	mov    0x14(%ebp),%eax
  1018f6:	83 e8 04             	sub    $0x4,%eax
  1018f9:	8b 00                	mov    (%eax),%eax
  1018fb:	ba 00 00 00 00       	mov    $0x0,%edx
  101900:	89 45 d8             	mov    %eax,-0x28(%ebp)
  101903:	89 55 dc             	mov    %edx,-0x24(%ebp)
			base = 16;
  101906:	c7 45 e0 10 00 00 00 	movl   $0x10,-0x20(%ebp)
			goto number;
  10190d:	eb 1f                	jmp    10192e <vprintfmt+0x39f>

		// (unsigned) hexadecimal
		case 'x':
			num = getuint(&ap, lflag);
  10190f:	8b 45 ec             	mov    -0x14(%ebp),%eax
  101912:	89 44 24 04          	mov    %eax,0x4(%esp)
  101916:	8d 45 14             	lea    0x14(%ebp),%eax
  101919:	89 04 24             	mov    %eax,(%esp)
  10191c:	e8 6f fb ff ff       	call   101490 <getuint>
  101921:	89 45 d8             	mov    %eax,-0x28(%ebp)
  101924:	89 55 dc             	mov    %edx,-0x24(%ebp)
			base = 16;
  101927:	c7 45 e0 10 00 00 00 	movl   $0x10,-0x20(%ebp)
		number:
			printnum(putch, putdat, num, base, width, padc);
  10192e:	0f be 55 f7          	movsbl -0x9(%ebp),%edx
  101932:	8b 45 e0             	mov    -0x20(%ebp),%eax
  101935:	89 54 24 18          	mov    %edx,0x18(%esp)
  101939:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  10193c:	89 54 24 14          	mov    %edx,0x14(%esp)
  101940:	89 44 24 10          	mov    %eax,0x10(%esp)
  101944:	8b 45 d8             	mov    -0x28(%ebp),%eax
  101947:	8b 55 dc             	mov    -0x24(%ebp),%edx
  10194a:	89 44 24 08          	mov    %eax,0x8(%esp)
  10194e:	89 54 24 0c          	mov    %edx,0xc(%esp)
  101952:	8b 45 0c             	mov    0xc(%ebp),%eax
  101955:	89 44 24 04          	mov    %eax,0x4(%esp)
  101959:	8b 45 08             	mov    0x8(%ebp),%eax
  10195c:	89 04 24             	mov    %eax,(%esp)
  10195f:	e8 28 fa ff ff       	call   10138c <printnum>
			break;
  101964:	eb 3b                	jmp    1019a1 <vprintfmt+0x412>

		// escaped '%' character
		case '%':
			putch(ch, putdat);
  101966:	8b 45 0c             	mov    0xc(%ebp),%eax
  101969:	89 44 24 04          	mov    %eax,0x4(%esp)
  10196d:	89 1c 24             	mov    %ebx,(%esp)
  101970:	8b 45 08             	mov    0x8(%ebp),%eax
  101973:	ff d0                	call   *%eax
			break;
  101975:	eb 2a                	jmp    1019a1 <vprintfmt+0x412>

		// unrecognized escape sequence - just print it literally
		default:
			putch('%', putdat);
  101977:	8b 45 0c             	mov    0xc(%ebp),%eax
  10197a:	89 44 24 04          	mov    %eax,0x4(%esp)
  10197e:	c7 04 24 25 00 00 00 	movl   $0x25,(%esp)
  101985:	8b 45 08             	mov    0x8(%ebp),%eax
  101988:	ff d0                	call   *%eax
			for (fmt --; fmt[-1] != '%'; fmt --)
  10198a:	83 6d 10 01          	subl   $0x1,0x10(%ebp)
  10198e:	eb 04                	jmp    101994 <vprintfmt+0x405>
  101990:	83 6d 10 01          	subl   $0x1,0x10(%ebp)
  101994:	8b 45 10             	mov    0x10(%ebp),%eax
  101997:	83 e8 01             	sub    $0x1,%eax
  10199a:	0f b6 00             	movzbl (%eax),%eax
  10199d:	3c 25                	cmp    $0x25,%al
  10199f:	75 ef                	jne    101990 <vprintfmt+0x401>
				/* do nothing */;
			break;
		}
	}
  1019a1:	90                   	nop
	register int ch, err;
	unsigned long long num;
	int base, width, precision, lflag, altflag;

	while (1) {
		while ((ch = *(unsigned char *)fmt ++) != '%') {
  1019a2:	e9 09 fc ff ff       	jmp    1015b0 <vprintfmt+0x21>
			for (fmt --; fmt[-1] != '%'; fmt --)
				/* do nothing */;
			break;
		}
	}
}
  1019a7:	83 c4 40             	add    $0x40,%esp
  1019aa:	5b                   	pop    %ebx
  1019ab:	5e                   	pop    %esi
  1019ac:	5d                   	pop    %ebp
  1019ad:	c3                   	ret    

001019ae <sprintputch>:
 * sprintputch - 'print' a single character in a buffer
 * @ch:			the character will be printed
 * @b:			the buffer to place the character @ch
 * */
static void
sprintputch(int ch, struct sprintbuf *b) {
  1019ae:	55                   	push   %ebp
  1019af:	89 e5                	mov    %esp,%ebp
	b->cnt ++;
  1019b1:	8b 45 0c             	mov    0xc(%ebp),%eax
  1019b4:	8b 40 08             	mov    0x8(%eax),%eax
  1019b7:	8d 50 01             	lea    0x1(%eax),%edx
  1019ba:	8b 45 0c             	mov    0xc(%ebp),%eax
  1019bd:	89 50 08             	mov    %edx,0x8(%eax)
	if (b->buf < b->ebuf) {
  1019c0:	8b 45 0c             	mov    0xc(%ebp),%eax
  1019c3:	8b 10                	mov    (%eax),%edx
  1019c5:	8b 45 0c             	mov    0xc(%ebp),%eax
  1019c8:	8b 40 04             	mov    0x4(%eax),%eax
  1019cb:	39 c2                	cmp    %eax,%edx
  1019cd:	73 12                	jae    1019e1 <sprintputch+0x33>
		*b->buf ++ = ch;
  1019cf:	8b 45 0c             	mov    0xc(%ebp),%eax
  1019d2:	8b 00                	mov    (%eax),%eax
  1019d4:	8b 55 08             	mov    0x8(%ebp),%edx
  1019d7:	88 10                	mov    %dl,(%eax)
  1019d9:	8d 50 01             	lea    0x1(%eax),%edx
  1019dc:	8b 45 0c             	mov    0xc(%ebp),%eax
  1019df:	89 10                	mov    %edx,(%eax)
	}
}
  1019e1:	5d                   	pop    %ebp
  1019e2:	c3                   	ret    

001019e3 <snprintf>:
 * @str:		the buffer to place the result into
 * @size:		the size of buffer, including the trailing null space
 * @fmt:		the format string to use
 * */
int
snprintf(char *str, size_t size, const char *fmt, ...) {
  1019e3:	55                   	push   %ebp
  1019e4:	89 e5                	mov    %esp,%ebp
  1019e6:	83 ec 28             	sub    $0x28,%esp
	va_list ap;
	int cnt;
	va_start(ap, fmt);
  1019e9:	8d 45 10             	lea    0x10(%ebp),%eax
  1019ec:	83 c0 04             	add    $0x4,%eax
  1019ef:	89 45 f0             	mov    %eax,-0x10(%ebp)
	cnt = vsnprintf(str, size, fmt, ap);
  1019f2:	8b 45 10             	mov    0x10(%ebp),%eax
  1019f5:	8b 55 f0             	mov    -0x10(%ebp),%edx
  1019f8:	89 54 24 0c          	mov    %edx,0xc(%esp)
  1019fc:	89 44 24 08          	mov    %eax,0x8(%esp)
  101a00:	8b 45 0c             	mov    0xc(%ebp),%eax
  101a03:	89 44 24 04          	mov    %eax,0x4(%esp)
  101a07:	8b 45 08             	mov    0x8(%ebp),%eax
  101a0a:	89 04 24             	mov    %eax,(%esp)
  101a0d:	e8 08 00 00 00       	call   101a1a <vsnprintf>
  101a12:	89 45 f4             	mov    %eax,-0xc(%ebp)
	va_end(ap);
	return cnt;
  101a15:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  101a18:	c9                   	leave  
  101a19:	c3                   	ret    

00101a1a <vsnprintf>:
 *
 * Call this function if you are already dealing with a va_list.
 * Or you probably want snprintf() instead.
 * */
int
vsnprintf(char *str, size_t size, const char *fmt, va_list ap) {
  101a1a:	55                   	push   %ebp
  101a1b:	89 e5                	mov    %esp,%ebp
  101a1d:	83 ec 28             	sub    $0x28,%esp
	struct sprintbuf b = {str, str + size - 1, 0};
  101a20:	8b 45 0c             	mov    0xc(%ebp),%eax
  101a23:	83 e8 01             	sub    $0x1,%eax
  101a26:	03 45 08             	add    0x8(%ebp),%eax
  101a29:	8b 55 08             	mov    0x8(%ebp),%edx
  101a2c:	89 55 ec             	mov    %edx,-0x14(%ebp)
  101a2f:	89 45 f0             	mov    %eax,-0x10(%ebp)
  101a32:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
	if (str == NULL || b.buf > b.ebuf) {
  101a39:	83 7d 08 00          	cmpl   $0x0,0x8(%ebp)
  101a3d:	74 0a                	je     101a49 <vsnprintf+0x2f>
  101a3f:	8b 55 ec             	mov    -0x14(%ebp),%edx
  101a42:	8b 45 f0             	mov    -0x10(%ebp),%eax
  101a45:	39 c2                	cmp    %eax,%edx
  101a47:	76 07                	jbe    101a50 <vsnprintf+0x36>
		return -E_INVAL;
  101a49:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  101a4e:	eb 2b                	jmp    101a7b <vsnprintf+0x61>
	}
	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  101a50:	b8 ae 19 10 00       	mov    $0x1019ae,%eax
  101a55:	8b 55 14             	mov    0x14(%ebp),%edx
  101a58:	89 54 24 0c          	mov    %edx,0xc(%esp)
  101a5c:	8b 55 10             	mov    0x10(%ebp),%edx
  101a5f:	89 54 24 08          	mov    %edx,0x8(%esp)
  101a63:	8d 55 ec             	lea    -0x14(%ebp),%edx
  101a66:	89 54 24 04          	mov    %edx,0x4(%esp)
  101a6a:	89 04 24             	mov    %eax,(%esp)
  101a6d:	e8 1d fb ff ff       	call   10158f <vprintfmt>
	// null terminate the buffer
	*b.buf = '\0';
  101a72:	8b 45 ec             	mov    -0x14(%ebp),%eax
  101a75:	c6 00 00             	movb   $0x0,(%eax)
	return b.cnt;
  101a78:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  101a7b:	c9                   	leave  
  101a7c:	c3                   	ret    
  101a7d:	00 00                	add    %al,(%eax)
	...

00101a80 <strlen>:
 * @s:		the input string
 *
 * The strlen() function returns the length of string @s.
 * */
size_t
strlen(const char *s) {
  101a80:	55                   	push   %ebp
  101a81:	89 e5                	mov    %esp,%ebp
  101a83:	83 ec 10             	sub    $0x10,%esp
	size_t cnt = 0;
  101a86:	c7 45 fc 00 00 00 00 	movl   $0x0,-0x4(%ebp)
	while (*s ++ != '\0') {
  101a8d:	eb 04                	jmp    101a93 <strlen+0x13>
		cnt ++;
  101a8f:	83 45 fc 01          	addl   $0x1,-0x4(%ebp)
 * The strlen() function returns the length of string @s.
 * */
size_t
strlen(const char *s) {
	size_t cnt = 0;
	while (*s ++ != '\0') {
  101a93:	8b 45 08             	mov    0x8(%ebp),%eax
  101a96:	0f b6 00             	movzbl (%eax),%eax
  101a99:	84 c0                	test   %al,%al
  101a9b:	0f 95 c0             	setne  %al
  101a9e:	83 45 08 01          	addl   $0x1,0x8(%ebp)
  101aa2:	84 c0                	test   %al,%al
  101aa4:	75 e9                	jne    101a8f <strlen+0xf>
		cnt ++;
	}
	return cnt;
  101aa6:	8b 45 fc             	mov    -0x4(%ebp),%eax
}
  101aa9:	c9                   	leave  
  101aaa:	c3                   	ret    

00101aab <strnlen>:
 * The return value is strlen(s), if that is less than @len, or
 * @len if there is no '\0' character among the first @len characters
 * pointed by @s.
 * */
size_t
strnlen(const char *s, size_t len) {
  101aab:	55                   	push   %ebp
  101aac:	89 e5                	mov    %esp,%ebp
  101aae:	83 ec 10             	sub    $0x10,%esp
	size_t cnt = 0;
  101ab1:	c7 45 fc 00 00 00 00 	movl   $0x0,-0x4(%ebp)
	while (cnt < len && *s ++ != '\0') {
  101ab8:	eb 04                	jmp    101abe <strnlen+0x13>
		cnt ++;
  101aba:	83 45 fc 01          	addl   $0x1,-0x4(%ebp)
 * pointed by @s.
 * */
size_t
strnlen(const char *s, size_t len) {
	size_t cnt = 0;
	while (cnt < len && *s ++ != '\0') {
  101abe:	8b 45 fc             	mov    -0x4(%ebp),%eax
  101ac1:	3b 45 0c             	cmp    0xc(%ebp),%eax
  101ac4:	73 13                	jae    101ad9 <strnlen+0x2e>
  101ac6:	8b 45 08             	mov    0x8(%ebp),%eax
  101ac9:	0f b6 00             	movzbl (%eax),%eax
  101acc:	84 c0                	test   %al,%al
  101ace:	0f 95 c0             	setne  %al
  101ad1:	83 45 08 01          	addl   $0x1,0x8(%ebp)
  101ad5:	84 c0                	test   %al,%al
  101ad7:	75 e1                	jne    101aba <strnlen+0xf>
		cnt ++;
	}
	return cnt;
  101ad9:	8b 45 fc             	mov    -0x4(%ebp),%eax
}
  101adc:	c9                   	leave  
  101add:	c3                   	ret    

00101ade <strcpy>:
 * To avoid overflows, the size of array pointed by @dst should be long enough to
 * contain the same string as @src (including the terminating null character), and
 * should not overlap in memory with @src.
 * */
char *
strcpy(char *dst, const char *src) {
  101ade:	55                   	push   %ebp
  101adf:	89 e5                	mov    %esp,%ebp
  101ae1:	57                   	push   %edi
  101ae2:	56                   	push   %esi
  101ae3:	83 ec 20             	sub    $0x20,%esp
  101ae6:	8b 45 08             	mov    0x8(%ebp),%eax
  101ae9:	89 45 e8             	mov    %eax,-0x18(%ebp)
  101aec:	8b 45 0c             	mov    0xc(%ebp),%eax
  101aef:	89 45 e4             	mov    %eax,-0x1c(%ebp)
#ifndef __HAVE_ARCH_STRCPY
#define __HAVE_ARCH_STRCPY
static inline char *
__strcpy(char *dst, const char *src) {
	int d0, d1, d2;
	asm volatile (
  101af2:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  101af5:	8b 45 e8             	mov    -0x18(%ebp),%eax
  101af8:	89 d1                	mov    %edx,%ecx
  101afa:	89 c2                	mov    %eax,%edx
  101afc:	89 ce                	mov    %ecx,%esi
  101afe:	89 d7                	mov    %edx,%edi
  101b00:	ac                   	lods   %ds:(%esi),%al
  101b01:	aa                   	stos   %al,%es:(%edi)
  101b02:	84 c0                	test   %al,%al
  101b04:	75 fa                	jne    101b00 <strcpy+0x22>
  101b06:	89 fa                	mov    %edi,%edx
  101b08:	89 f1                	mov    %esi,%ecx
  101b0a:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  101b0d:	89 55 f0             	mov    %edx,-0x10(%ebp)
  101b10:	89 45 ec             	mov    %eax,-0x14(%ebp)
			"stosb;"
			"testb %%al, %%al;"
			"jne 1b;"
			: "=&S" (d0), "=&D" (d1), "=&a" (d2)
			: "0" (src), "1" (dst) : "memory");
	return dst;
  101b13:	8b 45 e8             	mov    -0x18(%ebp),%eax
	char *p = dst;
	while ((*p ++ = *src ++) != '\0')
		/* nothing */;
	return dst;
#endif /* __HAVE_ARCH_STRCPY */
}
  101b16:	83 c4 20             	add    $0x20,%esp
  101b19:	5e                   	pop    %esi
  101b1a:	5f                   	pop    %edi
  101b1b:	5d                   	pop    %ebp
  101b1c:	c3                   	ret    

00101b1d <strncpy>:
 * @len:	maximum number of characters to be copied from @src
 *
 * The return value is @dst
 * */
char *
strncpy(char *dst, const char *src, size_t len) {
  101b1d:	55                   	push   %ebp
  101b1e:	89 e5                	mov    %esp,%ebp
  101b20:	83 ec 10             	sub    $0x10,%esp
	char *p = dst;
  101b23:	8b 45 08             	mov    0x8(%ebp),%eax
  101b26:	89 45 fc             	mov    %eax,-0x4(%ebp)
	while (len > 0) {
  101b29:	eb 21                	jmp    101b4c <strncpy+0x2f>
		if ((*p = *src) != '\0') {
  101b2b:	8b 45 0c             	mov    0xc(%ebp),%eax
  101b2e:	0f b6 10             	movzbl (%eax),%edx
  101b31:	8b 45 fc             	mov    -0x4(%ebp),%eax
  101b34:	88 10                	mov    %dl,(%eax)
  101b36:	8b 45 fc             	mov    -0x4(%ebp),%eax
  101b39:	0f b6 00             	movzbl (%eax),%eax
  101b3c:	84 c0                	test   %al,%al
  101b3e:	74 04                	je     101b44 <strncpy+0x27>
			src ++;
  101b40:	83 45 0c 01          	addl   $0x1,0xc(%ebp)
		}
		p ++, len --;
  101b44:	83 45 fc 01          	addl   $0x1,-0x4(%ebp)
  101b48:	83 6d 10 01          	subl   $0x1,0x10(%ebp)
 * The return value is @dst
 * */
char *
strncpy(char *dst, const char *src, size_t len) {
	char *p = dst;
	while (len > 0) {
  101b4c:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  101b50:	75 d9                	jne    101b2b <strncpy+0xe>
		if ((*p = *src) != '\0') {
			src ++;
		}
		p ++, len --;
	}
	return dst;
  101b52:	8b 45 08             	mov    0x8(%ebp),%eax
}
  101b55:	c9                   	leave  
  101b56:	c3                   	ret    

00101b57 <strcmp>:
 * - A value greater than zero indicates that the first character that does
 *   not match has a greater value in @s1 than in @s2;
 * - And a value less than zero indicates the opposite.
 * */
int
strcmp(const char *s1, const char *s2) {
  101b57:	55                   	push   %ebp
  101b58:	89 e5                	mov    %esp,%ebp
  101b5a:	57                   	push   %edi
  101b5b:	56                   	push   %esi
  101b5c:	83 ec 20             	sub    $0x20,%esp
  101b5f:	8b 45 08             	mov    0x8(%ebp),%eax
  101b62:	89 45 e8             	mov    %eax,-0x18(%ebp)
  101b65:	8b 45 0c             	mov    0xc(%ebp),%eax
  101b68:	89 45 e4             	mov    %eax,-0x1c(%ebp)
#ifndef __HAVE_ARCH_STRCMP
#define __HAVE_ARCH_STRCMP
static inline int
__strcmp(const char *s1, const char *s2) {
	int d0, d1, ret;
	asm volatile (
  101b6b:	8b 55 e8             	mov    -0x18(%ebp),%edx
  101b6e:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  101b71:	89 d1                	mov    %edx,%ecx
  101b73:	89 c2                	mov    %eax,%edx
  101b75:	89 ce                	mov    %ecx,%esi
  101b77:	89 d7                	mov    %edx,%edi
  101b79:	ac                   	lods   %ds:(%esi),%al
  101b7a:	ae                   	scas   %es:(%edi),%al
  101b7b:	75 08                	jne    101b85 <strcmp+0x2e>
  101b7d:	84 c0                	test   %al,%al
  101b7f:	75 f8                	jne    101b79 <strcmp+0x22>
  101b81:	31 c0                	xor    %eax,%eax
  101b83:	eb 04                	jmp    101b89 <strcmp+0x32>
  101b85:	19 c0                	sbb    %eax,%eax
  101b87:	0c 01                	or     $0x1,%al
  101b89:	89 fa                	mov    %edi,%edx
  101b8b:	89 f1                	mov    %esi,%ecx
  101b8d:	89 45 ec             	mov    %eax,-0x14(%ebp)
  101b90:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  101b93:	89 55 f0             	mov    %edx,-0x10(%ebp)
			"orb $1, %%al;"
			"3:"
			: "=a" (ret), "=&S" (d0), "=&D" (d1)
			: "1" (s1), "2" (s2)
			: "memory");
	return ret;
  101b96:	8b 45 ec             	mov    -0x14(%ebp),%eax
	while (*s1 != '\0' && *s1 == *s2) {
		s1 ++, s2 ++;
	}
	return (int)((unsigned char)*s1 - (unsigned char)*s2);
#endif /* __HAVE_ARCH_STRCMP */
}
  101b99:	83 c4 20             	add    $0x20,%esp
  101b9c:	5e                   	pop    %esi
  101b9d:	5f                   	pop    %edi
  101b9e:	5d                   	pop    %ebp
  101b9f:	c3                   	ret    

00101ba0 <strncmp>:
 * they are equal to each other, it continues with the following pairs until
 * the characters differ, until a terminating null-character is reached, or
 * until @n characters match in both strings, whichever happens first.
 * */
int
strncmp(const char *s1, const char *s2, size_t n) {
  101ba0:	55                   	push   %ebp
  101ba1:	89 e5                	mov    %esp,%ebp
	while (n > 0 && *s1 != '\0' && *s1 == *s2) {
  101ba3:	eb 0c                	jmp    101bb1 <strncmp+0x11>
		n --, s1 ++, s2 ++;
  101ba5:	83 6d 10 01          	subl   $0x1,0x10(%ebp)
  101ba9:	83 45 08 01          	addl   $0x1,0x8(%ebp)
  101bad:	83 45 0c 01          	addl   $0x1,0xc(%ebp)
 * the characters differ, until a terminating null-character is reached, or
 * until @n characters match in both strings, whichever happens first.
 * */
int
strncmp(const char *s1, const char *s2, size_t n) {
	while (n > 0 && *s1 != '\0' && *s1 == *s2) {
  101bb1:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  101bb5:	74 1a                	je     101bd1 <strncmp+0x31>
  101bb7:	8b 45 08             	mov    0x8(%ebp),%eax
  101bba:	0f b6 00             	movzbl (%eax),%eax
  101bbd:	84 c0                	test   %al,%al
  101bbf:	74 10                	je     101bd1 <strncmp+0x31>
  101bc1:	8b 45 08             	mov    0x8(%ebp),%eax
  101bc4:	0f b6 10             	movzbl (%eax),%edx
  101bc7:	8b 45 0c             	mov    0xc(%ebp),%eax
  101bca:	0f b6 00             	movzbl (%eax),%eax
  101bcd:	38 c2                	cmp    %al,%dl
  101bcf:	74 d4                	je     101ba5 <strncmp+0x5>
		n --, s1 ++, s2 ++;
	}
	return (n == 0) ? 0 : (int)((unsigned char)*s1 - (unsigned char)*s2);
  101bd1:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  101bd5:	74 1a                	je     101bf1 <strncmp+0x51>
  101bd7:	8b 45 08             	mov    0x8(%ebp),%eax
  101bda:	0f b6 00             	movzbl (%eax),%eax
  101bdd:	0f b6 d0             	movzbl %al,%edx
  101be0:	8b 45 0c             	mov    0xc(%ebp),%eax
  101be3:	0f b6 00             	movzbl (%eax),%eax
  101be6:	0f b6 c0             	movzbl %al,%eax
  101be9:	89 d1                	mov    %edx,%ecx
  101beb:	29 c1                	sub    %eax,%ecx
  101bed:	89 c8                	mov    %ecx,%eax
  101bef:	eb 05                	jmp    101bf6 <strncmp+0x56>
  101bf1:	b8 00 00 00 00       	mov    $0x0,%eax
}
  101bf6:	5d                   	pop    %ebp
  101bf7:	c3                   	ret    

00101bf8 <strchr>:
 *
 * The strchr() function returns a pointer to the first occurrence of
 * character in @s. If the value is not found, the function returns 'NULL'.
 * */
char *
strchr(const char *s, char c) {
  101bf8:	55                   	push   %ebp
  101bf9:	89 e5                	mov    %esp,%ebp
  101bfb:	83 ec 04             	sub    $0x4,%esp
  101bfe:	8b 45 0c             	mov    0xc(%ebp),%eax
  101c01:	88 45 fc             	mov    %al,-0x4(%ebp)
	while (*s != '\0') {
  101c04:	eb 14                	jmp    101c1a <strchr+0x22>
		if (*s == c) {
  101c06:	8b 45 08             	mov    0x8(%ebp),%eax
  101c09:	0f b6 00             	movzbl (%eax),%eax
  101c0c:	3a 45 fc             	cmp    -0x4(%ebp),%al
  101c0f:	75 05                	jne    101c16 <strchr+0x1e>
			return (char *)s;
  101c11:	8b 45 08             	mov    0x8(%ebp),%eax
  101c14:	eb 13                	jmp    101c29 <strchr+0x31>
		}
		s ++;
  101c16:	83 45 08 01          	addl   $0x1,0x8(%ebp)
 * The strchr() function returns a pointer to the first occurrence of
 * character in @s. If the value is not found, the function returns 'NULL'.
 * */
char *
strchr(const char *s, char c) {
	while (*s != '\0') {
  101c1a:	8b 45 08             	mov    0x8(%ebp),%eax
  101c1d:	0f b6 00             	movzbl (%eax),%eax
  101c20:	84 c0                	test   %al,%al
  101c22:	75 e2                	jne    101c06 <strchr+0xe>
		if (*s == c) {
			return (char *)s;
		}
		s ++;
	}
	return NULL;
  101c24:	b8 00 00 00 00       	mov    $0x0,%eax
}
  101c29:	c9                   	leave  
  101c2a:	c3                   	ret    

00101c2b <strfind>:
 * The strfind() function is like strchr() except that if @c is
 * not found in @s, then it returns a pointer to the null byte at the
 * end of @s, rather than 'NULL'.
 * */
char *
strfind(const char *s, char c) {
  101c2b:	55                   	push   %ebp
  101c2c:	89 e5                	mov    %esp,%ebp
  101c2e:	83 ec 04             	sub    $0x4,%esp
  101c31:	8b 45 0c             	mov    0xc(%ebp),%eax
  101c34:	88 45 fc             	mov    %al,-0x4(%ebp)
	while (*s != '\0') {
  101c37:	eb 0f                	jmp    101c48 <strfind+0x1d>
		if (*s == c) {
  101c39:	8b 45 08             	mov    0x8(%ebp),%eax
  101c3c:	0f b6 00             	movzbl (%eax),%eax
  101c3f:	3a 45 fc             	cmp    -0x4(%ebp),%al
  101c42:	74 10                	je     101c54 <strfind+0x29>
			break;
		}
		s ++;
  101c44:	83 45 08 01          	addl   $0x1,0x8(%ebp)
 * not found in @s, then it returns a pointer to the null byte at the
 * end of @s, rather than 'NULL'.
 * */
char *
strfind(const char *s, char c) {
	while (*s != '\0') {
  101c48:	8b 45 08             	mov    0x8(%ebp),%eax
  101c4b:	0f b6 00             	movzbl (%eax),%eax
  101c4e:	84 c0                	test   %al,%al
  101c50:	75 e7                	jne    101c39 <strfind+0xe>
  101c52:	eb 01                	jmp    101c55 <strfind+0x2a>
		if (*s == c) {
			break;
  101c54:	90                   	nop
		}
		s ++;
	}
	return (char *)s;
  101c55:	8b 45 08             	mov    0x8(%ebp),%eax
}
  101c58:	c9                   	leave  
  101c59:	c3                   	ret    

00101c5a <strtol>:
 * an optional "0x" or "0X" prefix.
 *
 * The strtol() function returns the converted integral number as a long int value.
 * */
long
strtol(const char *s, char **endptr, int base) {
  101c5a:	55                   	push   %ebp
  101c5b:	89 e5                	mov    %esp,%ebp
  101c5d:	83 ec 10             	sub    $0x10,%esp
	int neg = 0;
  101c60:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
	long val = 0;
  101c67:	c7 45 f8 00 00 00 00 	movl   $0x0,-0x8(%ebp)

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t') {
  101c6e:	eb 04                	jmp    101c74 <strtol+0x1a>
		s ++;
  101c70:	83 45 08 01          	addl   $0x1,0x8(%ebp)
strtol(const char *s, char **endptr, int base) {
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t') {
  101c74:	8b 45 08             	mov    0x8(%ebp),%eax
  101c77:	0f b6 00             	movzbl (%eax),%eax
  101c7a:	3c 20                	cmp    $0x20,%al
  101c7c:	74 f2                	je     101c70 <strtol+0x16>
  101c7e:	8b 45 08             	mov    0x8(%ebp),%eax
  101c81:	0f b6 00             	movzbl (%eax),%eax
  101c84:	3c 09                	cmp    $0x9,%al
  101c86:	74 e8                	je     101c70 <strtol+0x16>
		s ++;
	}

	// plus/minus sign
	if (*s == '+') {
  101c88:	8b 45 08             	mov    0x8(%ebp),%eax
  101c8b:	0f b6 00             	movzbl (%eax),%eax
  101c8e:	3c 2b                	cmp    $0x2b,%al
  101c90:	75 06                	jne    101c98 <strtol+0x3e>
		s ++;
  101c92:	83 45 08 01          	addl   $0x1,0x8(%ebp)
  101c96:	eb 15                	jmp    101cad <strtol+0x53>
	}
	else if (*s == '-') {
  101c98:	8b 45 08             	mov    0x8(%ebp),%eax
  101c9b:	0f b6 00             	movzbl (%eax),%eax
  101c9e:	3c 2d                	cmp    $0x2d,%al
  101ca0:	75 0b                	jne    101cad <strtol+0x53>
		s ++, neg = 1;
  101ca2:	83 45 08 01          	addl   $0x1,0x8(%ebp)
  101ca6:	c7 45 f4 01 00 00 00 	movl   $0x1,-0xc(%ebp)
	}

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x')) {
  101cad:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  101cb1:	74 06                	je     101cb9 <strtol+0x5f>
  101cb3:	83 7d 10 10          	cmpl   $0x10,0x10(%ebp)
  101cb7:	75 24                	jne    101cdd <strtol+0x83>
  101cb9:	8b 45 08             	mov    0x8(%ebp),%eax
  101cbc:	0f b6 00             	movzbl (%eax),%eax
  101cbf:	3c 30                	cmp    $0x30,%al
  101cc1:	75 1a                	jne    101cdd <strtol+0x83>
  101cc3:	8b 45 08             	mov    0x8(%ebp),%eax
  101cc6:	83 c0 01             	add    $0x1,%eax
  101cc9:	0f b6 00             	movzbl (%eax),%eax
  101ccc:	3c 78                	cmp    $0x78,%al
  101cce:	75 0d                	jne    101cdd <strtol+0x83>
		s += 2, base = 16;
  101cd0:	83 45 08 02          	addl   $0x2,0x8(%ebp)
  101cd4:	c7 45 10 10 00 00 00 	movl   $0x10,0x10(%ebp)
	else if (*s == '-') {
		s ++, neg = 1;
	}

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x')) {
  101cdb:	eb 2a                	jmp    101d07 <strtol+0xad>
		s += 2, base = 16;
	}
	else if (base == 0 && s[0] == '0') {
  101cdd:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  101ce1:	75 17                	jne    101cfa <strtol+0xa0>
  101ce3:	8b 45 08             	mov    0x8(%ebp),%eax
  101ce6:	0f b6 00             	movzbl (%eax),%eax
  101ce9:	3c 30                	cmp    $0x30,%al
  101ceb:	75 0d                	jne    101cfa <strtol+0xa0>
		s ++, base = 8;
  101ced:	83 45 08 01          	addl   $0x1,0x8(%ebp)
  101cf1:	c7 45 10 08 00 00 00 	movl   $0x8,0x10(%ebp)

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x')) {
		s += 2, base = 16;
	}
	else if (base == 0 && s[0] == '0') {
  101cf8:	eb 0d                	jmp    101d07 <strtol+0xad>
		s ++, base = 8;
	}
	else if (base == 0) {
  101cfa:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  101cfe:	75 07                	jne    101d07 <strtol+0xad>
		base = 10;
  101d00:	c7 45 10 0a 00 00 00 	movl   $0xa,0x10(%ebp)

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9') {
  101d07:	8b 45 08             	mov    0x8(%ebp),%eax
  101d0a:	0f b6 00             	movzbl (%eax),%eax
  101d0d:	3c 2f                	cmp    $0x2f,%al
  101d0f:	7e 1b                	jle    101d2c <strtol+0xd2>
  101d11:	8b 45 08             	mov    0x8(%ebp),%eax
  101d14:	0f b6 00             	movzbl (%eax),%eax
  101d17:	3c 39                	cmp    $0x39,%al
  101d19:	7f 11                	jg     101d2c <strtol+0xd2>
			dig = *s - '0';
  101d1b:	8b 45 08             	mov    0x8(%ebp),%eax
  101d1e:	0f b6 00             	movzbl (%eax),%eax
  101d21:	0f be c0             	movsbl %al,%eax
  101d24:	83 e8 30             	sub    $0x30,%eax
  101d27:	89 45 fc             	mov    %eax,-0x4(%ebp)

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9') {
  101d2a:	eb 48                	jmp    101d74 <strtol+0x11a>
			dig = *s - '0';
		}
		else if (*s >= 'a' && *s <= 'z') {
  101d2c:	8b 45 08             	mov    0x8(%ebp),%eax
  101d2f:	0f b6 00             	movzbl (%eax),%eax
  101d32:	3c 60                	cmp    $0x60,%al
  101d34:	7e 1b                	jle    101d51 <strtol+0xf7>
  101d36:	8b 45 08             	mov    0x8(%ebp),%eax
  101d39:	0f b6 00             	movzbl (%eax),%eax
  101d3c:	3c 7a                	cmp    $0x7a,%al
  101d3e:	7f 11                	jg     101d51 <strtol+0xf7>
			dig = *s - 'a' + 10;
  101d40:	8b 45 08             	mov    0x8(%ebp),%eax
  101d43:	0f b6 00             	movzbl (%eax),%eax
  101d46:	0f be c0             	movsbl %al,%eax
  101d49:	83 e8 57             	sub    $0x57,%eax
  101d4c:	89 45 fc             	mov    %eax,-0x4(%ebp)
		int dig;

		if (*s >= '0' && *s <= '9') {
			dig = *s - '0';
		}
		else if (*s >= 'a' && *s <= 'z') {
  101d4f:	eb 23                	jmp    101d74 <strtol+0x11a>
			dig = *s - 'a' + 10;
		}
		else if (*s >= 'A' && *s <= 'Z') {
  101d51:	8b 45 08             	mov    0x8(%ebp),%eax
  101d54:	0f b6 00             	movzbl (%eax),%eax
  101d57:	3c 40                	cmp    $0x40,%al
  101d59:	7e 38                	jle    101d93 <strtol+0x139>
  101d5b:	8b 45 08             	mov    0x8(%ebp),%eax
  101d5e:	0f b6 00             	movzbl (%eax),%eax
  101d61:	3c 5a                	cmp    $0x5a,%al
  101d63:	7f 2e                	jg     101d93 <strtol+0x139>
			dig = *s - 'A' + 10;
  101d65:	8b 45 08             	mov    0x8(%ebp),%eax
  101d68:	0f b6 00             	movzbl (%eax),%eax
  101d6b:	0f be c0             	movsbl %al,%eax
  101d6e:	83 e8 37             	sub    $0x37,%eax
  101d71:	89 45 fc             	mov    %eax,-0x4(%ebp)
		}
		else {
			break;
		}
		if (dig >= base) {
  101d74:	8b 45 fc             	mov    -0x4(%ebp),%eax
  101d77:	3b 45 10             	cmp    0x10(%ebp),%eax
  101d7a:	7d 16                	jge    101d92 <strtol+0x138>
			break;
		}
		s ++, val = (val * base) + dig;
  101d7c:	83 45 08 01          	addl   $0x1,0x8(%ebp)
  101d80:	8b 45 f8             	mov    -0x8(%ebp),%eax
  101d83:	0f af 45 10          	imul   0x10(%ebp),%eax
  101d87:	03 45 fc             	add    -0x4(%ebp),%eax
  101d8a:	89 45 f8             	mov    %eax,-0x8(%ebp)
		// we don't properly detect overflow!
	}
  101d8d:	e9 75 ff ff ff       	jmp    101d07 <strtol+0xad>
		}
		else {
			break;
		}
		if (dig >= base) {
			break;
  101d92:	90                   	nop
		}
		s ++, val = (val * base) + dig;
		// we don't properly detect overflow!
	}

	if (endptr) {
  101d93:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  101d97:	74 08                	je     101da1 <strtol+0x147>
		*endptr = (char *) s;
  101d99:	8b 45 0c             	mov    0xc(%ebp),%eax
  101d9c:	8b 55 08             	mov    0x8(%ebp),%edx
  101d9f:	89 10                	mov    %edx,(%eax)
	}
	return (neg ? -val : val);
  101da1:	83 7d f4 00          	cmpl   $0x0,-0xc(%ebp)
  101da5:	74 07                	je     101dae <strtol+0x154>
  101da7:	8b 45 f8             	mov    -0x8(%ebp),%eax
  101daa:	f7 d8                	neg    %eax
  101dac:	eb 03                	jmp    101db1 <strtol+0x157>
  101dae:	8b 45 f8             	mov    -0x8(%ebp),%eax
}
  101db1:	c9                   	leave  
  101db2:	c3                   	ret    

00101db3 <memset>:
 * @n:		number of bytes to be set to the value
 *
 * The memset() function returns @s.
 * */
void *
memset(void *s, char c, size_t n) {
  101db3:	55                   	push   %ebp
  101db4:	89 e5                	mov    %esp,%ebp
  101db6:	57                   	push   %edi
  101db7:	83 ec 24             	sub    $0x24,%esp
  101dba:	8b 45 0c             	mov    0xc(%ebp),%eax
  101dbd:	88 45 d8             	mov    %al,-0x28(%ebp)
#ifdef __HAVE_ARCH_MEMSET
	return __memset(s, c, n);
  101dc0:	0f be 45 d8          	movsbl -0x28(%ebp),%eax
  101dc4:	8b 55 08             	mov    0x8(%ebp),%edx
  101dc7:	89 55 f0             	mov    %edx,-0x10(%ebp)
  101dca:	88 45 ef             	mov    %al,-0x11(%ebp)
  101dcd:	8b 45 10             	mov    0x10(%ebp),%eax
  101dd0:	89 45 e8             	mov    %eax,-0x18(%ebp)
#ifndef __HAVE_ARCH_MEMSET
#define __HAVE_ARCH_MEMSET
static inline void *
__memset(void *s, char c, size_t n) {
	int d0, d1;
	asm volatile (
  101dd3:	8b 4d e8             	mov    -0x18(%ebp),%ecx
  101dd6:	0f b6 45 ef          	movzbl -0x11(%ebp),%eax
  101dda:	8b 55 f0             	mov    -0x10(%ebp),%edx
  101ddd:	89 d7                	mov    %edx,%edi
  101ddf:	f3 aa                	rep stos %al,%es:(%edi)
  101de1:	89 fa                	mov    %edi,%edx
  101de3:	89 4d f8             	mov    %ecx,-0x8(%ebp)
  101de6:	89 55 f4             	mov    %edx,-0xc(%ebp)
			"rep; stosb;"
			: "=&c" (d0), "=&D" (d1)
			: "0" (n), "a" (c), "1" (s)
			: "memory");
	return s;
  101de9:	8b 45 f0             	mov    -0x10(%ebp),%eax
	while (n -- > 0) {
		*p ++ = c;
	}
	return s;
#endif /* __HAVE_ARCH_MEMSET */
}
  101dec:	83 c4 24             	add    $0x24,%esp
  101def:	5f                   	pop    %edi
  101df0:	5d                   	pop    %ebp
  101df1:	c3                   	ret    

00101df2 <memmove>:
 * @n:		number of bytes to copy
 *
 * The memmove() function returns @dst.
 * */
void *
memmove(void *dst, const void *src, size_t n) {
  101df2:	55                   	push   %ebp
  101df3:	89 e5                	mov    %esp,%ebp
  101df5:	57                   	push   %edi
  101df6:	56                   	push   %esi
  101df7:	83 ec 30             	sub    $0x30,%esp
  101dfa:	8b 45 08             	mov    0x8(%ebp),%eax
  101dfd:	89 45 d0             	mov    %eax,-0x30(%ebp)
  101e00:	8b 45 0c             	mov    0xc(%ebp),%eax
  101e03:	89 45 cc             	mov    %eax,-0x34(%ebp)
  101e06:	8b 45 10             	mov    0x10(%ebp),%eax
  101e09:	89 45 c8             	mov    %eax,-0x38(%ebp)

#ifndef __HAVE_ARCH_MEMMOVE
#define __HAVE_ARCH_MEMMOVE
static inline void *
__memmove(void *dst, const void *src, size_t n) {
	if (dst < src) {
  101e0c:	8b 45 d0             	mov    -0x30(%ebp),%eax
  101e0f:	3b 45 cc             	cmp    -0x34(%ebp),%eax
  101e12:	73 42                	jae    101e56 <memmove+0x64>
  101e14:	8b 45 d0             	mov    -0x30(%ebp),%eax
  101e17:	89 45 e8             	mov    %eax,-0x18(%ebp)
  101e1a:	8b 45 cc             	mov    -0x34(%ebp),%eax
  101e1d:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  101e20:	8b 45 c8             	mov    -0x38(%ebp),%eax
  101e23:	89 45 e0             	mov    %eax,-0x20(%ebp)
			"andl $3, %%ecx;"
			"jz 1f;"
			"rep; movsb;"
			"1:"
			: "=&c" (d0), "=&D" (d1), "=&S" (d2)
			: "0" (n / 4), "g" (n), "1" (dst), "2" (src)
  101e26:	8b 45 e0             	mov    -0x20(%ebp),%eax
  101e29:	89 c1                	mov    %eax,%ecx
  101e2b:	c1 e9 02             	shr    $0x2,%ecx
#ifndef __HAVE_ARCH_MEMCPY
#define __HAVE_ARCH_MEMCPY
static inline void *
__memcpy(void *dst, const void *src, size_t n) {
	int d0, d1, d2;
	asm volatile (
  101e2e:	8b 55 e8             	mov    -0x18(%ebp),%edx
  101e31:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  101e34:	89 d7                	mov    %edx,%edi
  101e36:	89 c6                	mov    %eax,%esi
  101e38:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
  101e3a:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  101e3d:	83 e1 03             	and    $0x3,%ecx
  101e40:	74 02                	je     101e44 <memmove+0x52>
  101e42:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
  101e44:	89 f0                	mov    %esi,%eax
  101e46:	89 fa                	mov    %edi,%edx
  101e48:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  101e4b:	89 55 f0             	mov    %edx,-0x10(%ebp)
  101e4e:	89 45 ec             	mov    %eax,-0x14(%ebp)
			"rep; movsb;"
			"1:"
			: "=&c" (d0), "=&D" (d1), "=&S" (d2)
			: "0" (n / 4), "g" (n), "1" (dst), "2" (src)
			: "memory");
	return dst;
  101e51:	8b 45 e8             	mov    -0x18(%ebp),%eax
  101e54:	eb 2f                	jmp    101e85 <memmove+0x93>
	asm volatile (
			"std;"
			"rep; movsb;"
			"cld;"
			: "=&c" (d0), "=&S" (d1), "=&D" (d2)
			: "0" (n), "1" (n - 1 + src), "2" (n - 1 + dst)
  101e56:	8b 45 c8             	mov    -0x38(%ebp),%eax
  101e59:	83 e8 01             	sub    $0x1,%eax
  101e5c:	89 c2                	mov    %eax,%edx
  101e5e:	03 55 cc             	add    -0x34(%ebp),%edx
  101e61:	8b 45 c8             	mov    -0x38(%ebp),%eax
  101e64:	83 e8 01             	sub    $0x1,%eax
  101e67:	03 45 d0             	add    -0x30(%ebp),%eax
__memmove(void *dst, const void *src, size_t n) {
	if (dst < src) {
		return __memcpy(dst, src, n);
	}
	int d0, d1, d2;
	asm volatile (
  101e6a:	8b 4d c8             	mov    -0x38(%ebp),%ecx
  101e6d:	89 d6                	mov    %edx,%esi
  101e6f:	89 c7                	mov    %eax,%edi
  101e71:	fd                   	std    
  101e72:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
  101e74:	fc                   	cld    
  101e75:	89 f8                	mov    %edi,%eax
  101e77:	89 f2                	mov    %esi,%edx
  101e79:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  101e7c:	89 55 d8             	mov    %edx,-0x28(%ebp)
  101e7f:	89 45 d4             	mov    %eax,-0x2c(%ebp)
			"rep; movsb;"
			"cld;"
			: "=&c" (d0), "=&S" (d1), "=&D" (d2)
			: "0" (n), "1" (n - 1 + src), "2" (n - 1 + dst)
			: "memory");
	return dst;
  101e82:	8b 45 d0             	mov    -0x30(%ebp),%eax
			*d ++ = *s ++;
		}
	}
	return dst;
#endif /* __HAVE_ARCH_MEMMOVE */
}
  101e85:	83 c4 30             	add    $0x30,%esp
  101e88:	5e                   	pop    %esi
  101e89:	5f                   	pop    %edi
  101e8a:	5d                   	pop    %ebp
  101e8b:	c3                   	ret    

00101e8c <memcpy>:
 * it always copies exactly @n bytes. To avoid overflows, the size of arrays pointed
 * by both @src and @dst, should be at least @n bytes, and should not overlap
 * (for overlapping memory area, memmove is a safer approach).
 * */
void *
memcpy(void *dst, const void *src, size_t n) {
  101e8c:	55                   	push   %ebp
  101e8d:	89 e5                	mov    %esp,%ebp
  101e8f:	57                   	push   %edi
  101e90:	56                   	push   %esi
  101e91:	83 ec 20             	sub    $0x20,%esp
  101e94:	8b 45 08             	mov    0x8(%ebp),%eax
  101e97:	89 45 e8             	mov    %eax,-0x18(%ebp)
  101e9a:	8b 45 0c             	mov    0xc(%ebp),%eax
  101e9d:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  101ea0:	8b 45 10             	mov    0x10(%ebp),%eax
  101ea3:	89 45 e0             	mov    %eax,-0x20(%ebp)
			"andl $3, %%ecx;"
			"jz 1f;"
			"rep; movsb;"
			"1:"
			: "=&c" (d0), "=&D" (d1), "=&S" (d2)
			: "0" (n / 4), "g" (n), "1" (dst), "2" (src)
  101ea6:	8b 45 e0             	mov    -0x20(%ebp),%eax
  101ea9:	89 c1                	mov    %eax,%ecx
  101eab:	c1 e9 02             	shr    $0x2,%ecx
#ifndef __HAVE_ARCH_MEMCPY
#define __HAVE_ARCH_MEMCPY
static inline void *
__memcpy(void *dst, const void *src, size_t n) {
	int d0, d1, d2;
	asm volatile (
  101eae:	8b 55 e8             	mov    -0x18(%ebp),%edx
  101eb1:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  101eb4:	89 d7                	mov    %edx,%edi
  101eb6:	89 c6                	mov    %eax,%esi
  101eb8:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
  101eba:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  101ebd:	83 e1 03             	and    $0x3,%ecx
  101ec0:	74 02                	je     101ec4 <memcpy+0x38>
  101ec2:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
  101ec4:	89 f0                	mov    %esi,%eax
  101ec6:	89 fa                	mov    %edi,%edx
  101ec8:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  101ecb:	89 55 f0             	mov    %edx,-0x10(%ebp)
  101ece:	89 45 ec             	mov    %eax,-0x14(%ebp)
			"rep; movsb;"
			"1:"
			: "=&c" (d0), "=&D" (d1), "=&S" (d2)
			: "0" (n / 4), "g" (n), "1" (dst), "2" (src)
			: "memory");
	return dst;
  101ed1:	8b 45 e8             	mov    -0x18(%ebp),%eax
	while (n -- > 0) {
		*d ++ = *s ++;
	}
	return dst;
#endif /* __HAVE_ARCH_MEMCPY */
}
  101ed4:	83 c4 20             	add    $0x20,%esp
  101ed7:	5e                   	pop    %esi
  101ed8:	5f                   	pop    %edi
  101ed9:	5d                   	pop    %ebp
  101eda:	c3                   	ret    

00101edb <memcmp>:
 *   match in both memory blocks has a greater value in @v1 than in @v2
 *   as if evaluated as unsigned char values;
 * - And a value less than zero indicates the opposite.
 * */
int
memcmp(const void *v1, const void *v2, size_t n) {
  101edb:	55                   	push   %ebp
  101edc:	89 e5                	mov    %esp,%ebp
  101ede:	83 ec 10             	sub    $0x10,%esp
	const char *s1 = (const char *)v1;
  101ee1:	8b 45 08             	mov    0x8(%ebp),%eax
  101ee4:	89 45 f8             	mov    %eax,-0x8(%ebp)
	const char *s2 = (const char *)v2;
  101ee7:	8b 45 0c             	mov    0xc(%ebp),%eax
  101eea:	89 45 fc             	mov    %eax,-0x4(%ebp)
	while (n -- > 0) {
  101eed:	eb 32                	jmp    101f21 <memcmp+0x46>
		if (*s1 != *s2) {
  101eef:	8b 45 f8             	mov    -0x8(%ebp),%eax
  101ef2:	0f b6 10             	movzbl (%eax),%edx
  101ef5:	8b 45 fc             	mov    -0x4(%ebp),%eax
  101ef8:	0f b6 00             	movzbl (%eax),%eax
  101efb:	38 c2                	cmp    %al,%dl
  101efd:	74 1a                	je     101f19 <memcmp+0x3e>
			return (int)((unsigned char)*s1 - (unsigned char)*s2);
  101eff:	8b 45 f8             	mov    -0x8(%ebp),%eax
  101f02:	0f b6 00             	movzbl (%eax),%eax
  101f05:	0f b6 d0             	movzbl %al,%edx
  101f08:	8b 45 fc             	mov    -0x4(%ebp),%eax
  101f0b:	0f b6 00             	movzbl (%eax),%eax
  101f0e:	0f b6 c0             	movzbl %al,%eax
  101f11:	89 d1                	mov    %edx,%ecx
  101f13:	29 c1                	sub    %eax,%ecx
  101f15:	89 c8                	mov    %ecx,%eax
  101f17:	eb 1c                	jmp    101f35 <memcmp+0x5a>
		}
		s1 ++, s2 ++;
  101f19:	83 45 f8 01          	addl   $0x1,-0x8(%ebp)
  101f1d:	83 45 fc 01          	addl   $0x1,-0x4(%ebp)
 * */
int
memcmp(const void *v1, const void *v2, size_t n) {
	const char *s1 = (const char *)v1;
	const char *s2 = (const char *)v2;
	while (n -- > 0) {
  101f21:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  101f25:	0f 95 c0             	setne  %al
  101f28:	83 6d 10 01          	subl   $0x1,0x10(%ebp)
  101f2c:	84 c0                	test   %al,%al
  101f2e:	75 bf                	jne    101eef <memcmp+0x14>
		if (*s1 != *s2) {
			return (int)((unsigned char)*s1 - (unsigned char)*s2);
		}
		s1 ++, s2 ++;
	}
	return 0;
  101f30:	b8 00 00 00 00       	mov    $0x0,%eax
}
  101f35:	c9                   	leave  
  101f36:	c3                   	ret    
